A command-line tool to generate folder and file structures from YAML templates
Project description
Scaffolder
A command-line tool to generate folder and file structures from YAML templates.
Features
- 🚀 Fast: Uses asynchronous I/O for efficient file operations
- 🛠️ Simple: Define your project structure in a simple YAML file
- 🎨 Visual: Rich console output with color-coded status messages
- 🔄 Non-destructive: Asks for confirmation before overwriting existing files
- 🧩 Flexible: Creates files with or without content, nested directories, and more
- 📊 Preview: Visualize your project structure before generating it
- 🔧 Templates: Built-in templates for common project structures
Installation
pip install scfldr
Or install from source:
git clone https://github.com/utkarshg1/scfldr.git
cd scfldr
pip install -e .
Usage
Creating Your Project Structure
Create a YAML template file to define your desired file structure:
# template.yaml
src:
main.py: |
def main():
print("Hello, world!")
if __name__ == "__main__":
main()
utils:
helpers.py: |
def add(a, b):
return a + b
docs:
README.md: |
# My Project
This is a sample project.
tests:
test_main.py: |
def test_sample():
assert True
# Example with append mode
logs:
app.log: # Standard write mode (overwrites if file exists)
content: |
# Log file initialized
# App started
error.log: # Append mode (adds content if file exists)
content: |
# Error log entry
# Will be appended if the file exists
mode: a
Then generate your project structure:
scfldr generate-structure --template template.yaml --output my_project
Creating Example Templates
You can quickly create example template files:
scfldr create-example --type basic --output my_template.yaml
scfldr create-example --type web --output web_template.yaml
scfldr create-example --type python_package --output pkg_template.yaml
Previewing Structure
Preview the structure defined in your template without generating files:
scfldr show-structure --template template.yaml
Command Line Options
Usage: scfldr [COMMAND] [OPTIONS]
Generate folder/file structure from a YAML template.
Commands:
generate-structure Generate a project structure from a YAML template
show-structure Preview the directory structure from a YAML template
create-template-file Create a YAML template file from predefined examples
create-example Generate an example YAML template file
Options:
--help Show this message and exit
Generate Structure Options:
--template PATH Path to the YAML template. [default: template.yaml]
--output PATH Output directory root. [default: .]
--force / --no-force Overwrite existing output directory if it exists.
Show Structure Options:
--template PATH Path to the YAML template. [default: template.yaml]
Create Template File Options:
TEMPLATE_NAME Name of the template to create (e.g., 'basic', 'web', 'python_package')
--output-path PATH Output path for the YAML template file. [default: template.yaml]
Create Example Options:
--output PATH Path to save the example template. [default: template.yaml]
--type TEXT Type of template to generate (basic, web, python_package). [default: basic]
--force / --no-force Overwrite existing file if it exists.
YAML Template Format
The YAML template follows a simple structure:
- Keys represent directory or file names
- Values represent:
- For directories: A nested dictionary defining child entities
- For files:
- String content (can be multiline using YAML's
|syntax) - OR a dictionary with
contentand optionalmodekeysmode: ato append content to an existing filemode: w(default) to create or overwrite a file
- String content (can be multiline using YAML's
- For empty directories: An empty dictionary
{}
Examples:
# Basic structure
project:
src:
main.py: |
def main():
print("Hello, world!")
utils: {} # Empty directory
README.md: "# Project Title"
# Structure with append mode
project:
src:
main.py: |
def main():
print("Hello, world!")
logs:
app.log: # Standard write mode (default)
content: "Log entry"
error.log: # Append mode
content: "Error message"
mode: a # 'a' for append, 'w' for write (default)
Predefined Templates
Scaffolder comes with several predefined templates that you can use to quickly start a project:
Basic Template
A simple project structure with source files, documentation, and tests.
scfldr create-template-file basic --output-path basic_template.yaml
Web Template
A Flask web application with static files, templates, and basic setup.
scfldr create-template-file web --output-path web_template.yaml
Python Package Template
A standard Python package structure with tests, setup.py, and more.
scfldr create-template-file python_package --output-path package_template.yaml
Development
Requirements
- Python 3.7+
- Dependencies:
- typer
- pyyaml
- asyncio
- aiofiles
- rich
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scfldr-0.1.4.tar.gz.
File metadata
- Download URL: scfldr-0.1.4.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a961e5783343c57fefea4bff885493b1aa06d9da77413f5648513c892b30d265
|
|
| MD5 |
e09ef39ff1b219798f71ea16aa2978ce
|
|
| BLAKE2b-256 |
ed6c773b3568f5df11c419347433683faa65678a805d8b39f01a8aaa48d66848
|
File details
Details for the file scfldr-0.1.4-py3-none-any.whl.
File metadata
- Download URL: scfldr-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db0a4d5f5fcb6195aefa40c55272279f97a075431b9ecdc0787aaff0fa6fc277
|
|
| MD5 |
7ea5deb73b804a2baaf61f790bee81a3
|
|
| BLAKE2b-256 |
978f03a2590006dfd9c16c31337a698317331b40d56008bb08eb281be88ae3a0
|