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::cli_match;
// Execute CLI with auto-discovered commands
cli_match().await?;§Programmatic Execution
ⓘ
use ggen_cli::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 - ggen v5.0.0 (Fresh Start + Init)
- conventions
- File-based project conventions for zero-config generation
- prelude
- Common imports and re-exports for CLI commands
- runtime
- Runtime utilities for bridging async/sync boundaries
- runtime_
helper - Runtime helper for sync CLI wrappers
Structs§
- CliBuilder
- Main builder for creating composable CLI applications
- Command
Router - Router for dispatching noun-verb commands
- RunResult
- Structured result for programmatic CLI execution (used by Node addon)
Functions§
- cli_
match - Main entry point using clap-noun-verb v4.0.2 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