diff --git a/src/cli.rs b/src/cli.rs index 7d9f812..d38d2d7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -37,14 +37,16 @@ pub struct Args { pub enum SubCommand { Add(self::add::Args), Edit(self::edit::Args), + #[clap(visible_alias("rm"))] Remove(self::remove::Args), Priority(self::priority::Args), - #[clap(alias("ls"))] + #[clap(visible_alias("ls"))] List, Start(self::start::Args), Pause, Finish(self::finish::Args), - Status, + #[clap(visible_alias("st"))] + Status(self::status::Args), } pub fn print_task_detail(task: &domain::Task) { diff --git a/src/cli/start.rs b/src/cli/start.rs index 7bb6348..966c14d 100644 --- a/src/cli/start.rs +++ b/src/cli/start.rs @@ -8,9 +8,6 @@ pub struct Args { #[clap(short, long)] open: bool, - #[clap(long)] - print_path: bool, - idx: Option, } @@ -21,17 +18,8 @@ pub fn execute(repo: impl Repository, args: Args) { Err(err) => return eprintln!("Cannot start task: {}", err), }; - if args.print_path { - println!( - "{}", - task.path - .unwrap_or_else(|| std::env::current_dir().expect("Cannot get current dir")) - .to_string_lossy() - ) - } else { - println!("The task was started successfully"); - print_task_detail(&task); - } + println!("The task was started successfully"); + print_task_detail(&task); if let (Some(link), true) = (task.link.as_ref(), args.open) { log::debug!("opening link..."); diff --git a/src/cli/status.rs b/src/cli/status.rs index 161acb6..467ba6a 100644 --- a/src/cli/status.rs +++ b/src/cli/status.rs @@ -1,17 +1,33 @@ use crate::cli::print_task_detail; +use crate::domain::CurrentTaskInfo; use crate::repo::Repository; -pub fn execute(repo: impl Repository) { - match repo.get_current_task_opt() { +#[derive(clap::Args)] +pub struct Args { + #[clap(long)] + print_path: bool, +} + +pub fn execute(repo: impl Repository, args: Args) { + let task = match repo.get_current_task_opt() { Ok(None) => { - eprintln!("You don't have an active task."); - } - Ok(Some(info)) => { - println!("Information about your current task:"); - print_task_detail(&info.task); + return eprintln!("You don't have an active task."); } + Ok(Some(CurrentTaskInfo { task, .. })) => task, Err(err) => { - eprintln!("Cannot read current task: {}", err); + return eprintln!("Cannot read current task: {}", err); } + }; + + if args.print_path { + println!( + "{}", + task.path + .unwrap_or_else(|| std::env::current_dir().expect("Cannot get current dir")) + .to_string_lossy() + ) + } else { + println!("Information about your current task:"); + print_task_detail(&task); } } diff --git a/src/main.rs b/src/main.rs index de94339..77f8903 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,8 +65,8 @@ fn main() { cli::SubCommand::Finish(args) => { cli::finish::execute(repo, args); } - cli::SubCommand::Status => { - cli::status::execute(repo); + cli::SubCommand::Status(args) => { + cli::status::execute(repo, args); } } }