Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generoo-2019.7.24.6.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

generoo-2019.7.24.6-py3-none-any.whl (27.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page