A powerful and flexible project generator CLI tool written in Go that helps you quickly scaffold new projects from templates.
- Generate project skeletons from customizable templates
- Support for multiple project types
- Flexible parameter system via command line flags or parameter files
- Template parameter inspection
- Customizable output directory
# Clone the repository
git clone https://github.com/dirtydriver/projgen.git
cd projgen
# Build and install
go install
go install github.com/dirtydriver/projgen@latest
projgen follows Unix-style command structure with subcommands. Two flags are required for all operations:
--template-dir
: Path to the template directory--type
: Type of project (e.g., maven, gradle, angular)
# Generate a new project
projgen --template-dir <dir> --type <type> generate [flags]
# Inspect template parameters
projgen --template-dir <dir> --type <type> inspect
# Show version
projgen version
-n, --name
: Name of the project (can also be provided via --parameter name=value)-o, --out
: Output directory (default: current directory)-p, --parameter
: Additional parameters in key=value format (can be used multiple times)-f, --file
: Path to a parameters file
- Generate a new project:
projgen --template-dir ./templates --type maven generate --name my-project
- Generate with custom parameters:
projgen --template-dir ./templates --type angular generate \
--parameter name=my-app \
--parameter version=1.0.0 \
--parameter author="John Doe"
- Use a parameters file:
projgen --template-dir ./templates --type gradle generate \
--name my-lib \
--file params.file
- Check template parameters:
projgen --template-dir ./templates --type maven inspect
projgen uses a powerful templating system that allows you to create and customize project templates. Templates are stored in the templates
directory and use the .tmpl
extension.
templates/
├── maven/ # Template for Maven projects
│ ├── pom.xml.tmpl
│ └── src/
├── gradle/ # Template for Gradle projects
│ ├── build.gradle.tmpl
│ └── settings.gradle.tmpl
└── angular/ # Template for Angular projects
└── ...
projgen uses Go's built-in template engine. For detailed documentation, visit the official text/template package documentation.
Common template syntax used in project generation:
{{.name}} # Access a parameter value
{{.group_id}} # Use snake_case for parameter names
{{if .test}} # Conditional block
{{.test}}
{{end}}
{{range .items}} # Loop through array/slice
{{.}}
{{end}}
{{$var := .name}} # Assign to variable
{{title .name}} # Use 'title' function to capitalize
You can create parameter files to store commonly used values. Parameter files use a simple key=value format:
name=my-project
version=1.0.0
author=John Doe
description=My awesome project
- Create a new directory in
templates/
for your project type - Add template files with the
.tmpl
extension - Use Go template syntax for variable substitution:
{{.variable_name}}
- Use
projgen inspect
to check required parameters
projgen/
├── cmd/ # Command line interface implementation
├── filescheck/ # File system operations and checks
├── project/ # Project generation logic
├── templater/ # Template processing and rendering
├── utils/ # Utility functions
└── version/ # Version information
To contribute to projgen:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the terms of the LICENSE file included in the repository.