cli: move printing the task path to the status subcommand
cli: add visible aliases for remove, list, status
This commit is contained in:
parent
238e4b0b03
commit
8f9d53ccb3
|
@ -37,14 +37,16 @@ pub struct Args {
|
||||||
pub enum SubCommand {
|
pub enum SubCommand {
|
||||||
Add(self::add::Args),
|
Add(self::add::Args),
|
||||||
Edit(self::edit::Args),
|
Edit(self::edit::Args),
|
||||||
|
#[clap(visible_alias("rm"))]
|
||||||
Remove(self::remove::Args),
|
Remove(self::remove::Args),
|
||||||
Priority(self::priority::Args),
|
Priority(self::priority::Args),
|
||||||
#[clap(alias("ls"))]
|
#[clap(visible_alias("ls"))]
|
||||||
List,
|
List,
|
||||||
Start(self::start::Args),
|
Start(self::start::Args),
|
||||||
Pause,
|
Pause,
|
||||||
Finish(self::finish::Args),
|
Finish(self::finish::Args),
|
||||||
Status,
|
#[clap(visible_alias("st"))]
|
||||||
|
Status(self::status::Args),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_task_detail(task: &domain::Task) {
|
pub fn print_task_detail(task: &domain::Task) {
|
||||||
|
|
|
@ -8,9 +8,6 @@ pub struct Args {
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
open: bool,
|
open: bool,
|
||||||
|
|
||||||
#[clap(long)]
|
|
||||||
print_path: bool,
|
|
||||||
|
|
||||||
idx: Option<usize>,
|
idx: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,17 +18,8 @@ pub fn execute(repo: impl Repository, args: Args) {
|
||||||
Err(err) => return eprintln!("Cannot start task: {}", err),
|
Err(err) => return eprintln!("Cannot start task: {}", err),
|
||||||
};
|
};
|
||||||
|
|
||||||
if args.print_path {
|
println!("The task was started successfully");
|
||||||
println!(
|
print_task_detail(&task);
|
||||||
"{}",
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let (Some(link), true) = (task.link.as_ref(), args.open) {
|
if let (Some(link), true) = (task.link.as_ref(), args.open) {
|
||||||
log::debug!("opening link...");
|
log::debug!("opening link...");
|
||||||
|
|
|
@ -1,17 +1,33 @@
|
||||||
use crate::cli::print_task_detail;
|
use crate::cli::print_task_detail;
|
||||||
|
use crate::domain::CurrentTaskInfo;
|
||||||
use crate::repo::Repository;
|
use crate::repo::Repository;
|
||||||
|
|
||||||
pub fn execute(repo: impl Repository) {
|
#[derive(clap::Args)]
|
||||||
match repo.get_current_task_opt() {
|
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) => {
|
Ok(None) => {
|
||||||
eprintln!("You don't have an active task.");
|
return eprintln!("You don't have an active task.");
|
||||||
}
|
|
||||||
Ok(Some(info)) => {
|
|
||||||
println!("Information about your current task:");
|
|
||||||
print_task_detail(&info.task);
|
|
||||||
}
|
}
|
||||||
|
Ok(Some(CurrentTaskInfo { task, .. })) => task,
|
||||||
Err(err) => {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ fn main() {
|
||||||
cli::SubCommand::Finish(args) => {
|
cli::SubCommand::Finish(args) => {
|
||||||
cli::finish::execute(repo, args);
|
cli::finish::execute(repo, args);
|
||||||
}
|
}
|
||||||
cli::SubCommand::Status => {
|
cli::SubCommand::Status(args) => {
|
||||||
cli::status::execute(repo);
|
cli::status::execute(repo, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue