scaffold the CLI, logging and turn research into TODOs
This commit is contained in:
commit
6aa7e23872
17 changed files with 888 additions and 0 deletions
42
src/cli.rs
Normal file
42
src/cli.rs
Normal 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,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue