Skip to content

Creating a New Project

Once you have a template downloaded, scaffold a new project with the new command:

portion new <template-name> <project-name>

Parameters:

  • <template-name> — Name of the downloaded template to use
  • <project-name> — Name for the new project directory

Example:

portion new cli-template my-awesome-app

This creates a my-awesome-app/ directory pre-populated with the structure defined in cli-template.

If you have multiple versions of the template installed, PyPortion will prompt you to choose which version to use.

Adding More Templates

A project can use more than one template. To attach an additional template to a project you've already created:

portion add <template-name>

Example:

portion add cli-template

This registers the template in your project's .pyportion.yml, making its portions available for use. If multiple versions are installed, you will be prompted to select which version to attach.

Remove a Template

To detach a template from your project:

portion remove <template-name>

This removes the template reference from .pyportion.yml. It does not delete any previously generated files.

View Project Info

Display the current project configuration and its attached templates:

portion info

Building Portions

A portion is a named, reusable code-generation recipe defined inside a template. Once a template is attached to your project, run any of its portions to scaffold new code:

portion build <portion-name>

Example — scaffold a new command using the cli-template:

portion build command

PyPortion prompts you for any required inputs, shows a summary of the changes it will make, and asks for confirmation before applying them.

Use the -y flag to skip the confirmation prompt:

portion -y build command

Next Steps