CLI Usage¶
embgen provides a command-line interface for generating code from YAML configuration files.
Basic Syntax¶
Global Options¶
| Option | Description |
|---|---|
--help, -h |
Show help message |
-d, --debug |
Enable debug output with timing information |
--domains-dir PATH |
Load additional domains from this directory |
Commands¶
Domain Subcommands¶
Each domain is exposed as a subcommand. The built-in domains are:
embgen commands INPUT -o OUTPUT [FLAGS] # Generate from command definitions
embgen registers INPUT -o OUTPUT [FLAGS] # Generate from register maps
Auto-detect Domain¶
Use auto to let embgen detect the domain from the YAML content:
Create New Domain¶
Use new to scaffold a new domain:
| Option | Description |
|---|---|
--location PATH |
Directory where the domain folder will be created |
--builtin |
Create the domain in embgen's built-in domains directory |
Domain-Specific Options¶
Common Options¶
All domain subcommands share these options:
| Option | Description |
|---|---|
INPUT |
Path to the YAML configuration file |
-o, --output PATH |
Output directory for generated files |
Output Format Flags¶
Each domain defines its own output format flags based on available templates:
| Flag | Output |
|---|---|
--h |
C header file (commands.h) |
--py |
Python module (commands.py + commands_base.py) |
--md |
Markdown documentation (commands.md) |
| Flag | Output |
|---|---|
--h |
C header file (<name>.h + reg_common.h/.c) |
--py |
Python module (<name>.py) |
--md |
Markdown documentation (<name>.md) |
Examples¶
Generate C Header Only¶
Generate Multiple Formats¶
Generate with Debug Output¶
This shows timing information:
[12:34:56] INFO Loading YAML file from mycommands.yml
[12:34:56] INFO Generating C Header... done after 0.02s
[12:34:56] INFO Generation complete in 0.05s
Auto-detect Domain Type¶
embgen examines the YAML structure to determine the appropriate domain:
- Files with a
commandskey → Commands domain - Files with a
regmapkey → Registers domain
Use Custom Domains¶
# Load domains from a custom directory
embgen --domains-dir ./my_domains mydom config.yml -o output/ --h
Create a New Domain¶
# Create in a custom location
embgen new mydomain --location ./domains
# Create as a built-in domain
embgen new mydomain --builtin
Environment Variables¶
| Variable | Description |
|---|---|
EMBGEN_DOMAINS_DIR |
Additional directory to search for domains |
This allows you to set up custom domains without specifying --domains-dir every time:
Exit Codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Error (invalid arguments, file not found, validation error, etc.) |
Error Handling¶
File Not Found¶
$ embgen commands nonexistent.yml -o output/ --h
ERROR Generation failed: Input file .../nonexistent.yml does not exist
No Output Format Specified¶
$ embgen commands config.yml -o output/
ERROR No output formats specified. Use -h to see available formats.