CLI tool to instantly generate skeleton project structure with boilerplate code, that's taken from configurable YAML file, to quickly kick-start your project
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.
$var: 1
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
$ cd ~
$ mkdir scaffolder
$ cd scaffolder
# 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
$ chmod +x scaffold
$ echo 'export PATH="$HOME/scaffolder:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
# cmd:
cd %userprofile%
# PowerShell:
cd $env:userprofile
mkdir scaffolder
cd scaffolder
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:
Note: Make sure to replace YourUsername with your actual Windows username.
To build Scaffolder from source, ensure you have Golang installed:
$ git clone https://github.com/dl-tg/scaffolder.git
$ cd scaffolder
$ 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.