Accio is a scaffolding tool for generating boilerplate code, written in Golang. You can use it to create templates for repetitive code patterns and generate them interactively whenever you need them. The best part about it is that Accio allows you to customize most aspects of code generation with custom scripts.
- Interactive data prompts - configure prompts and use data in templates;
- Scripting - write custom scripts to process input data;
- Remote generators - execute generators directly from Git repositories;
- No external dependencies - no need to install external applications, dependency managers, or other tools - everything works out of the box with a single binary;
- Cross-platform - builds for Linux, OS X, Windows, and others.
Homebrew:
brew install g1ntas/tap/accio
Shell script:
curl -sfL https://raw.githubusercontent.com/g1ntas/accio/master/install.sh | sh
Manually:
Download the pre-compiled binaries from releases page.
To build a binary from the source code, you need to have Go installed first.
Steps:
- Clone repository:
git clone https://github.com/g1ntas/accio
- Build:
go run mage.go build
- Run
./accio
to verify if it works
You can run a generator from a local directory with run
command:
accio run ./generator-directory
Or directly from Git repository:
accio run github.com/user/accio-generator-repo
Subdirectories are supported as well:
accio run github.com/g1ntas/accio/examples/open-source-license
Create a config file ~/example/.accio.toml
# A prompt to show when the generator is executed
[prompts.filename]
type="input"
message="Enter a filename:"
Create a template file ~/example/file.txt.accio
:
# Make a new variable containing the uppercase prompted filename
# with Starlark code
variable -name="uppercaseFilename" <<
return vars['filename'].upper()
>>
# Rename the file
filename <<
return vars['uppercaseFilename']
>>
# Use mustache templating engine to output content of the file
template <<
Name of this file is: {{uppercaseFilename}}
>>
And that's all it takes to create a simple generator - now you can run it:
> accio run ~/example
$ Enter a filename:
> test.txt
$ Running...
$ Done.
> cat ~/example/TEST.TXT
$ Name of this file is: TEST.TXT
To learn about more advanced features needed to write more complex generators, read the introduction tutorial.
- github.com/g1ntas/accio/examples/go-travisci-config - generates TravisCI config with selected Go versions, operating systems, and CPU architectures
- github.com/g1ntas/accio/examples/golang-cli-project - generates a boilerplate Go project with a Cobra CLI command
- github.com/g1ntas/accio/examples/open-source-license - generates the selected open-source license
- Introduction
- Core concepts
- Reference
Contributions are more than welcome, if you are interested please take a look to our Contributing Guidelines.
Accio is released under the MIT license. See LICENSE.