34 lines
880 B
Rust
34 lines
880 B
Rust
use crate::cli::print_task_detail;
|
|
use crate::domain::CurrentTaskInfo;
|
|
use crate::repo::Repository;
|
|
|
|
#[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) => {
|
|
return eprintln!("You don't have an active task.");
|
|
}
|
|
Ok(Some(CurrentTaskInfo { task, .. })) => task,
|
|
Err(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);
|
|
}
|
|
}
|