Expand description
§ggen-cli - Command-line interface for ggen code generation
This crate provides the command-line interface for ggen, using clap-noun-verb for automatic command discovery and routing. It bridges between user commands and the domain logic layer (ggen-domain).
§Architecture
- Command Discovery: Uses clap-noun-verb v3.4.0 auto-discovery to find
all
\[verb\]functions in thecmdsmodule - Async/Sync Bridge: Provides runtime utilities to bridge async domain functions with synchronous CLI execution
- Conventions: File-based routing conventions for template-based command generation
- Node Integration: Programmatic entry point for Node.js addon integration
§Features
- Auto-discovery: Commands are automatically discovered via clap-noun-verb
- Version handling: Built-in
--versionflag support - Output capture: Programmatic execution with stdout/stderr capture
- Async support: Full async/await support for non-blocking operations
§Examples
§Basic CLI Execution
use ggen_cli_lib::cli_match;
// Execute CLI with auto-discovered commands
cli_match().await?;§Programmatic Execution
ⓘ
use ggen_cli_lib::run_for_node;
let args = vec!["template".to_string(), "generate".to_string()];
let result = run_for_node(args).await?;
println!("Exit code: {}", result.code);
println!("Output: {}", result.stdout);Modules§
- cmds
- Command Router Module - clap-noun-verb v26.5.19 Auto-Discovery
- config_
clap - ggen-config-clap
- conventions
- File-based project conventions for zero-config generation
- error
- Semantic exit codes and error handling for ggen CLI
- pack_
install - Improved pack installation with better UX and performance
- prelude
- Common imports and re-exports for CLI commands
- progress
- Progress reporting system for pack installation
- receipt_
manager - Receipt manager for CLI operations
- runtime
- Runtime utilities for bridging async/sync boundaries
- runtime_
helper - Runtime helper for sync CLI wrappers
- validation_
lib - ggen-cli-validation
- version_
checker
Macros§
- map_err
- Macro for easy error conversion in CLI commands
Structs§
- RunResult
- Structured result for programmatic CLI execution (used by Node addon)
Functions§
- cli_
match - Main entry point using clap-noun-verb v26.5.19 auto-discovery
- run
- Auto-run CLI with all registered commands
- run_
for_ node - Programmatic entrypoint to execute the CLI with provided arguments and capture output. This avoids spawning a new process and preserves deterministic behavior.
Type Aliases§
- Clap
Noun Verb Result - Result type alias for noun-verb operations
- Result
- Result type alias for the ggen project