CLI argument definitions using clap.
Tutorial overview:
clapuses derive macros (#[derive(Parser)],#[derive(Subcommand)]) to turn Rust structs/enums into a command-line interface.- Struct fields become flags or positional args, based on
#[arg(...)]. - Enums represent subcommands, and nested enums represent sub-subcommands.
Folder layout
cli/
mod.rs ← this file: Cli + Commands + GitPassArgs +
print_completions + Commands::telemetry_names + re-exports
styles.rs ← help-output colour palette
workspace.rs ← WorkspaceCommands
stack.rs ← StackCommands
commit.rs ← CommitArgs
compare.rs ← CompareArgs
branch.rs ← BranchArgs + BranchSquashCmd
config.rs ← ConfigArgs
stats.rs ← StatsArgs
developer.rs ← DeveloperCommands
notes.rs ← NotesCommands
Every per-domain struct/enum is re-exported below so external call sites
continue to write use crate::cli::CommitArgs; (etc.) without caring
about the internal split.
Source:
src/cli/mod.rs