goscaffold

command module
v0.0.0-...-43d0979 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 5 Imported by: 0

README

GoScaffold

GoScaffold is a command-line tool written in Golang that simplifies project creation by generating boilerplate code from templates, similar to Python's Cookiecutter but leveraging Jinja2 templating engine.

Installation

To install GoScaffold, you need to have Golang installed on your system. Then you can install it using go get:

go get github.com/copito/goscaffold

Moreover, the tool will be compiled to an executable (with the latest version) under the bin folder. So you can use it directly without having to install it if you are testing quickly.

./bin/goscaffold

Usage

GoScaffold requires a template directory containing your project template files. You can use Jinja2 syntax within these template files to customize the generated code.

To create a new project from a template, use the goscaffold command followed by the template directory path and the destination directory:

goscaffold path/to/template -c path/to/config_file

For example:

goscaffold /home/user/scaffold/example -c example/example.config.yaml

This will generate a new project in the ~/Projects/myproject directory using the template located at ~/mytemplate.

Template Structure

Your template directory should follow a specific structure:

template/
|-- {{scaffold.project_name}}/
| |-- main.go
| |-- README.md
| |-- ...
|-- hooks
| -- pre_project_gen.sh
| -- post_project_gen.sh

Within your template files, you can use Jinja2 variables in double curly braces ({{ }}). These variables will be replaced with user input during project creation.

For example, if your template includes a file named README.md with the content:

# {{scaffold.project_name}}

During project creation, {{scaffold.project_name}} will be replaced with the user-provided project name.

Template Variables

You can define custom variables in a .scaffold.yaml file in your template directory. For example:

project_name: "MyProject"
author_name: "John Doe"
email: "john.doe@example.com"

These variables can then be used in your template files.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details. Feel free to customize it further based on your project's specifics!

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL