Generate code without writing any.
Project description
Generoo
When we start new projects, we often go through a similar set of steps to bootstrap it. As a developer, we want to spend time developing. That's where generoo comes in. Generoo allows developers to write a project template once and then generate new projects from that template in seconds. Project templating without any additional coding gives time back to developers so they can focus on writing core business logic.
For an in-depth look at Generoo and it's use, see the documentation.
Installation
PIP
Install the package from pip:
pip install generoo
Run from the module:
python -m generoo <goal> <scope> <name>
Source
Clone the project. Navigate to the directory on your machine.
Note: Generoo must be run in Python 3.6 and above.
You can run from the python interpreter by using the following command:
python generoo.py <goal> <scope> <name>
How does it work?
Generoo is simple. Create a template using Mustache's syntax for string replacement.
The template could be a file called examples/hello-world/hello_world.py
that looks like:
print('Hello, {{who}}')
Then, a template configuration file in JSON or YAML defines prompts for the user when they run Generoo. Here's an example
file called examples/hello-world/template-config.json
:
{
"prompts": [
{
"name": "who",
"text": "Enter who you want to say hello to"
}
]
}
The text is what the user will see when the prompt is shown and the name is the template value that will be replaced.
Running python3 generoo.py generate project hello-world --template examples/hello-world/hello_world.py --template-config examples/hello-world/template-config.json
will prompt the user:
$ Say hello to:
When user enters: World
, then the template is filled out and written to hello-world/hello_world.py
and looks like:
print('Hello, World')
For more information about how the templating system works, see the Generoo documentation.
Usage
Using generoo is simple. The CLI or python script takes 3 positional arguments:
generoo <goal> <scope> <name> [options...]
goal
- what you want generoo to do. Example:generate
scope
- what you want generoo to create. Example:project
name
- what you want to name what generoo is creating. This will be used as the root directory name. Example:example
Positional Arguments (in the order they appear):
Goals
Argument | Description | Aliases |
---|---|---|
generate |
Fill in templates for an archetype or custom user project. | gen , g |
Scopes
Argument | Description | Aliases |
---|---|---|
project |
Generates a new project with the given name. | project , proj , pro , p |
Options
Option | Description |
---|---|
-n , --no-config |
Will run generoo without a pre-existing configuration. |
-a , --auto-config |
Will run generoo using the pre-existing configuration and only prompt for values not present in the configuration. |
-c , --template-config |
Points to a location on the system that contains a custom template config. |
-t , --template |
Points to a directory on the system that contains templates for a corresponding template config. |
-r , --run-configuration |
Points to a file on the system that contains a run configuration for a corresponding template config. |
Built-In Templates
If no --template
or --template-config
arguments are given, then Generoo will generate from its built-in templates.
Check out the archetypes
directory to see the templates yourself. Or, better yet, try generating one.
Contributing
Have a template that you'd like to share? Submit a PR with the template and we'll see about getting it into the built-in templates for this project.
Want some new functionality? Open an issue or a PR with the changes you'd like to see.
Project details
Release history Release notifications | RSS feed
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
Hashes for generoo-2019.7.24.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33e611ad3fdf1a6f14dc0c7fa25b4c42fd927f43ed175bde88266d4919324c50 |
|
MD5 | 1ebf1fc4c759d633027f79f2aec61f18 |
|
BLAKE2b-256 | ff7c37aa7f0a6f7bb7e5d0f4dd22475ceaa028cd60b6f1d39ddee892c7439ad7 |