Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
/ accio Public archive

Accio is a flexible framework for boilerplate code generators

License

Notifications You must be signed in to change notification settings

g1ntas/accio

Repository files navigation

Accio


Linux, macOS and Windows Build Status Go Report Card codecov

About

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.

Features

  • 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.

Installation

Pre-compiled binaries

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.

Building from source

To build a binary from the source code, you need to have Go installed first.

Steps:

  1. Clone repository: git clone https://github.com/g1ntas/accio
  2. Build: go run mage.go build
  3. Run ./accio to verify if it works

Quickstart

Running generator

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

Creating first generator

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.

Examples

Documentation

Contributing

Contributions are more than welcome, if you are interested please take a look to our Contributing Guidelines.

Copyright

Accio is released under the MIT license. See LICENSE.