From c130780349ba008ff1077c3b988e92e439077aed Mon Sep 17 00:00:00 2001 From: haruki7049 Date: Wed, 6 Dec 2023 15:50:25 +0900 Subject: [PATCH] implemented sub_command and list option --- src/bin/kakei.rs | 33 +++++++++++++++++++++++++++++++++ src/main.rs | 3 --- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/bin/kakei.rs delete mode 100644 src/main.rs diff --git a/src/bin/kakei.rs b/src/bin/kakei.rs new file mode 100644 index 0000000..dadf59b --- /dev/null +++ b/src/bin/kakei.rs @@ -0,0 +1,33 @@ +use clap::Parser; + +fn main() { + let args: Args = Args::parse(); + let is_listed: bool = args.list; + + match args.sub_command.as_str() { + "set-income" => { + println!("set-income is running...") + } + "get-balance" => { + println!("{}", is_listed); + println!("get-balance is running...") + } + "set-expense" => { + println!("set-expense is running..."); + } + _ => { + eprintln!("Unknown command: {}", &args.sub_command); + } + } + +} + +#[derive(Debug, Parser)] +#[command(author, version, about)] +pub struct Args { + #[arg(help = "What you want to do")] + pub sub_command: String, + + #[arg(long, help = "If you want kakei to show as list, use --list")] + pub list: bool, +} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -}