From 45027ad826a0d7277653d958ab516349a7e8b4fc Mon Sep 17 00:00:00 2001 From: breadone Date: Sun, 10 Mar 2024 16:15:05 +1300 Subject: [PATCH] Have basic structure down --- src/main.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..148bf18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,53 @@ -fn main() { - println!("Hello, world!"); +use clap::{Parser, Subcommand}; + +#[derive(Subcommand)] +enum Command { + Git { + #[command(subcommand)] + git_command: GitCommand + } } + +#[derive(Subcommand)] +enum GitCommand { + Create { + #[arg()] + name: String + }, + + List, + + Delete { + #[arg()] + name: String + } +} + +#[derive(Parser)] +struct Cli { + #[command(subcommand)] + command: Command +} + +fn main() { + let args = Cli::parse(); + + match &args.command { + Command::Git { git_command } => { + handle_git(&git_command); + } + } +} + + +fn handle_git(cmd: &GitCommand) { + match cmd { + GitCommand::Create { name } => { + println!("{}", name); + } + + _ => { + println!("oopsies") + } + } +} \ No newline at end of file