//! The Command Line Interface definition to the git-identity subcommand use clap::{ArgAction, Args, Parser, Subcommand}; /// Manages multiple identities (e.g. personal, work, university, ...) in git repos for you. #[derive(Parser, Debug)] pub struct Cli { #[command(flatten)] pub global: GlobalArgs, #[command(subcommand)] pub command: Command, } impl Cli { pub fn run_subcommand(self) -> anyhow::Result<()> { match self.command { Command::SayHello(cli) => crate::subcommands::say_hello::main(self.global, cli), } } } /// Global arguments (not specific to any subcommand) #[derive(Args, Debug)] pub struct GlobalArgs { /// Increases the verbosity of the log outputs /// /// The RUST_LOG environment variable takes priority if both are specified. #[arg(short, long = "verbose", action = ArgAction::Count)] pub verbosity: u8, } #[derive(Subcommand, Debug)] pub enum Command { SayHello(SayHelloCli), } /// A temporary subcommand for testing the cli #[derive(Parser, Debug)] pub struct SayHelloCli { pub name: String, }