diff --git a/src/cli.rs b/src/cli.rs index 1cba9a1..6a199c8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -64,8 +64,11 @@ pub enum Commands { /// -> shift all uncompeleted in "today" to "tomorrow" Shift, - /// -> collect all uncompeleted in INBOX to "today" - Collect, + /// -> collect all uncompeleted in INBOX(or --inbox ) to "today" + Collect { + #[arg(short, long)] + inbox: Option, + }, /// -> postpone all uncompeleted of today to INBOX Postp, diff --git a/src/main.rs b/src/main.rs index 4c93226..fe973ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ fn main() { println!(" {} left!", "nothing".yellow()); } else { for t in tasks { - println!("{} {}", "󰄗".to_string().red(), t) + println!("{} {}", "󰄗".red(), t) } } @@ -137,8 +137,8 @@ fn main() { TaskBox::shift(inbox_path) } - Some(Commands::Collect) => { - TaskBox::collect(inbox_path) + Some(Commands::Collect { inbox }) => { + TaskBox::collect(inbox_path, inbox) } Some(Commands::Postp) => { diff --git a/src/taskbox.rs b/src/taskbox.rs index 28ed97d..d1fa67c 100644 --- a/src/taskbox.rs +++ b/src/taskbox.rs @@ -150,7 +150,7 @@ impl TaskBox { println!("{}  {} ↩️", from.unwrap().green(), to.unwrap().blue()); for task in tasks { - println!("{} : {}", " 󰄗".to_string().red(), task); + println!("{} : {}", " 󰄗".red(), task); self.tasks.push((task.clone(), false)); } @@ -266,12 +266,22 @@ impl TaskBox { } // INBOX -> today - pub fn collect(inbox_path: PathBuf) { + pub fn collect(inbox_path: PathBuf, inbox_from: Option) { let basedir = inbox_path.as_path().parent().unwrap(); + if inbox_from == Some(get_today()) { + println!("{} is not a valid source", "󰄹 today".red()); + return + } + let mut today_todo = TaskBox::new(basedir.join(get_today()).with_extension("md")); - let mut inbox_todo = TaskBox::new(basedir.join(INBOX_NAME).with_extension("md")); - today_todo._move_in(&mut inbox_todo) + let mut from_todo = if let Some(from_name) = inbox_from { + TaskBox::new(basedir.join(from_name).with_extension("md")) + } else { + TaskBox::new(basedir.join(INBOX_NAME).with_extension("md")) + }; + + today_todo._move_in(&mut from_todo) } // today -> INBOX @@ -298,13 +308,13 @@ impl TaskBox { if line.is_empty() { continue } if let Some(stripped) = line.strip_prefix(PREFIX) { - println!("{} : {}", " 󰄗".to_string().red(), stripped); + println!("{} : {}", " 󰄗".red(), stripped); newt.push((stripped.to_string(), false)) } } if newt.is_empty() { - println!("{} found", "nothing".to_string().yellow()) + println!("{} found", "nothing".yellow()) } else { self._load(); self.tasks.append(&mut newt); @@ -325,7 +335,7 @@ impl TaskBox { } boxes.sort(); boxes.reverse(); boxes.into_iter().for_each( |b| { - print!("{} {}","󰄹".to_string().blue(), b); + print!("{} {}","󰄹".blue(), b); let tbox = TaskBox::new(basedir.join(b).with_extension("md")); if tbox.alias.is_some() { println!(" ({})", tbox.alias.unwrap().bright_black().blink())