Command Summary#
| Command | Alias | Description | Short Syntax |
|---|---|---|---|
init | — | Initialize Lokio in the current project directory | lokio init |
gen | g | Generate code from a template | lokio gen |
add | a | Add a new template | lokio add |
edit <name> | e | Edit the configuration or contents of a template | lokio edit <name> |
remove <name> | rm | Remove a template | lokio remove <name> |
Global Options#
-V, --versionDisplays the Lokio CLI version.-h, --helpDisplays help for a command.-m, --multiA specific option foraddto create multi-file templates.
Examples:
lokio --version
lokio --help
lokio addinit — Initialize Project#
Initializes Lokio in the current project directory, creating a basic configuration and folder structure for storing templates.
Syntax:
lokio initGenerated structure:
project/
├── lokio.yaml # Project configuration
└── lokio/
├── configs.yaml # List of templates
└── templates/ # Folder for template files
└── example.lokio # Example template
Notes:
- Run this command from your project's root directory.
- The
lokio.yamlandlokio/configs.yamlfiles should be included in version control to share with the team.
gen / g — Generate from Template#
Generates code based on a registered template. Use a template name specified in configs.yaml.
Syntax:
lokio gen <template> [name]
# Or alias:
lokio g <template> [name]
# Or simply:
lokio gParameters:
<template>The name of the template you want to use (e.g.,screen,component,api).[name]The name of the instance or entity being generated (optional, depending on the template definition).
Examples:
lokio g
# Runs the generator (depends on default configuration/template)
lokio g screen Home
# Generates code for the 'screen' template with the name 'Home'Notes:
- The output location follows the template definition (
.lokio). - If the template requires additional input (variables), you will be prompted to provide it interactively or through configuration.
add / a — Add New Template#
Creates a new template inside the lokio/templates/ directory and registers it in configs.yaml.
Syntax:
lokio add <name> [--multi]
# Or alias:
lokio a <name> [--multi]
# Or simply:
lokio aOptions:
-m, --multiCreates a multi-file template (a structure with multiple files).
Examples:
lokio add component
# Adds a single-file template named 'component'
lokio add api --multi
# Adds a multi-file template named 'api'
lokio a
# Adds a template; next steps will prompt for inputResults:
- A
.lokiofile (single-file) or template directory (multi-file) is created inlokio/templates/. - Template entries are automatically added/updated in
lokio/configs.yaml.
edit / e — Edit Template#
Edit the contents or configuration of an existing template.
Syntax:
lokio edit <name>
# Or alias:
lokio e <name>Example:
lokio edit component
# Opens/prepares editing for the template named 'component'Notes:
- Ensure the template name matches the one registered in
configs.yaml. - After editing, test the template with
lokio gento ensure the output is as expected.
remove / rm — Remove Template#
Deletes a template from the project as well as its reference in configs.yaml.
Syntax:
lokio remove <name>
# Or alias:
lokio rm <name>Example:
lokio rm component
# Removes the template named 'component'Notes:
- This action deletes the template files/directory from
lokio/templates/. - Review the resulting changes before committing them to version control.
Integrated Usage Example#
# 1) Initialize Lokio for the project
lokio init
# 2) Add a multi-file template for API endpoints
lokio add api --multi
# 3) Edit the 'api' template if necessary (structure, variables, output path)
lokio edit api
# 4) Generate a new API endpoint named 'User'
lokio g api UserRecommended Practices#
- Include all configurations (
lokio.yaml,lokio/configs.yaml) and contents oflokio/templates/in version control. - Provide brief documentation for each template (purpose, variables, output location) to ensure all team members understand them.
- Regularly review and update templates to maintain consistency and quality in team workflow.
Additional Information#
- Quick help:
lokio --help lokio <command> --help - Installed version:
lokio --version