Skip to content

Commit

Permalink
implemented sub_command and list option
Browse files Browse the repository at this point in the history
  • Loading branch information
haruki7049 committed Dec 6, 2023
1 parent 52a8885 commit c130780
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
33 changes: 33 additions & 0 deletions src/bin/kakei.rs
Original file line number Diff line number Diff line change
@@ -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,
}
3 changes: 0 additions & 3 deletions src/main.rs

This file was deleted.

0 comments on commit c130780

Please sign in to comment.