Scaffolder is a powerful command-line interface tool written in Golang designed to automate the tedious task of creating barebones for your projects. It allows you to define the necessary directory structure in a reusable config YAML file, making it easy for both humans and parsers to work with.
- Specify default variables in YAML like
$var: 1
- Automate project scaffolding with a YAML config file
- Supports creating folders and files with custom content using simple YAML syntax
- Define and use variables in the YAML file for flexible project generation
- Remembers custom config directories using the --remember flag for added convenience
Suppose we have the following YAML config file named test.yaml:
hello1: # Folder name
hello.txt: | # File name
Hello World # File content
hello1.txt: # File name (empty)
hello2.txt: # File name (empty)
hello2: # Folder name
hello22.txt: # File name (empty)
We can scaffold a project named "hello" using this config:
$ scaffold --name hello --yaml test
The resulting directory structure will be:
hello
├── hello1
│ ├── hello.txt
│ ├── hello1.txt
│ └── hello2.txt
└── hello2
└── hello22.txt
The content of hello.txt will be:
Hello World
- Change your directory to the home directory:
$ cd ~
- Create a folder for Scaffolder and navigate there:
$ mkdir scaffolder
$ cd scaffolder
- Download the latest release:
# Linux:
$ wget -q -O scaffold https://github.com/cemister/scaffolder/releases/download/v1.1.9/scaffolder_linux
# MacOS:
$ curl -s -o scaffold https://github.com/cemister/scaffolder/releases/download/v1.1.9/scaffolder_macos
- Make the file executable:
$ chmod +x scaffold
- Add the executable to your PATH:
$ echo 'export PATH="$HOME/scaffolder:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
- Open Command Prompt (cmd) or PowerShell and change the directory to the user's home directory:
# cmd:
cd %userprofile%
# PowerShell:
cd $env:userprofile
- Create a folder named "scaffolder" and change the current directory to it:
mkdir scaffolder
cd scaffolder
- Download the latest Scaffolder Windows release:
curl -s -o scaffold.exe https://github.com/cemister/scaffolder/releases/download/v1.1.9/scaffolder_win.exe
Add the executable to the PATH in Windows:
- Press Win + S to open the Windows search bar
- Search for "Environment Variables" and select "Edit the system environment variables"
- In the System Properties window, click the "Environment Variables" button
- In the Environment Variables window, find the "Path" variable under "User variables" and click "Edit"
- Click "New," then enter the full path to the "scaffolder" folder (e.g., C:\Users\YourUsername\scaffolder) and click "OK" to add it to the PATH
Note: Make sure to replace YourUsername with your actual Windows username.
To build Scaffolder from source, ensure you have Golang installed:
- Clone the repository (Git should be installed):
$ git clone https://github.com/dl-tg/scaffolder.git
- Navigate to the project directory:
$ cd scaffolder
- Build the project:
$ go build
Use the following command to scaffold a project:
$ scaffold --name? <project_name> --yaml <config_name> --configdir? <path_to_custom_config_folder_if_exists> --git? <true/false> --remember? <true/false> --variables? <k:v>
Note: remember flag specifies whether to remember custom path specified in configdir, avoiding the need to specify it each time On 1.1.9 version and above, name flag is optional now and if not specified, it will scaffold in current directory.
To create a file inside the parent (project's) directory, use a "." collection:
.:
main.txt:
To create a subdirectory (folder inside a folder), create a new collection with its name as the name of the parent folder, followed by the name of the needed folder separated by a slash (/):
hello1:
hello.txt:
hello1.txt:
hello2.txt:
hello2:
hello22.txt:
hello2/hello3:
hello33.txt:
To create an empty folder, create an empty collection without values:
helloempty:
Variables were added in 1.1.7. Here's how to use them:
Assume we have the following YAML config named cpp.yaml:
src:
main.cpp: |
#include <iostream>
int main() {
std::cout << "Hello, {name}!" << std::endl;
return 0;
}
In this example, we've defined a variable {name} within the main.cpp file, which will be replaced with the actual value when we scaffold the project.
Now, let's scaffold a C++ project named "hello-cpp" using this config and provide a value for the {name} variable:
$ scaffold --name hello-cpp --yaml cpp --variables name:John
The resulting directory structure will be:
hello-cpp
└── src
└── main.cpp
The content of main.cpp will be:
#include <iostream>
int main() {
std::cout << "Hello, John!" << std::endl;
return 0;
}
As you can see, the {name} variable was replaced with "John" in the final project files. This allows you to customize the generated code or any other content based on the values you provide during scaffolding.
As of 1.1.8, support for variables in folder or file names was added. Just wrap it in double quotes like "{var}": ...
if using in folder/filenames.
If you want to contribute but are unsure how, refer to the official GitHub guide on Contributing to projects.
This project is licensed under the MIT license. See the LICENSE file for details.