Have basic structure down
This commit is contained in:
parent
f72bc5518b
commit
45027ad826
54
src/main.rs
54
src/main.rs
@ -1,3 +1,53 @@
|
|||||||
fn main() {
|
use clap::{Parser, Subcommand};
|
||||||
println!("Hello, world!");
|
|
||||||
|
#[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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user