scaffold the CLI, logging and turn research into TODOs

This commit is contained in:
kalmenn 2026-02-01 17:23:35 +01:00
commit 6aa7e23872
Signed by: kalmenn
GPG key ID: F500055C44BC3834
17 changed files with 888 additions and 0 deletions

42
src/cli.rs Normal file
View file

@ -0,0 +1,42 @@
//! 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,
}