A file-based task manager

Compare changes

Choose any two refs to compare.

+14 -6
+14 -6
src/main.rs
··· 86 86 all: bool, 87 87 #[arg(short = 'c', default_value_t = 10)] 88 88 count: usize, 89 + #[arg(short = 'i', default_value_t = false)] 90 + ids: bool 89 91 }, 90 92 91 93 /// Swaps the top two tasks on the stack. If there are less than 2 tasks on the stack, there is ··· 253 255 Commands::Init => command_init(dir), 254 256 Commands::Push { edit, body, title } => command_push(dir, edit, body, title), 255 257 Commands::Append { edit, body, title } => command_append(dir, edit, body, title), 256 - Commands::List { all, count } => command_list(dir, all, count), 258 + Commands::List { all, count, ids } => command_list(dir, all, ids, count), 257 259 Commands::Swap => command_swap(dir), 258 260 Commands::Show { 259 261 task_id, ··· 344 346 workspace.append_task(task) 345 347 } 346 348 347 - fn command_list(dir: PathBuf, all: bool, count: usize) -> Result<()> { 349 + fn command_list(dir: PathBuf, all: bool, only_print_ids: bool, count: usize) -> Result<()> { 348 350 let workspace = Workspace::from_path(dir)?; 349 351 let stack = workspace.read_stack()?; 350 352 ··· 358 360 .enumerate() 359 361 .take_while(|(idx, _)| all || idx < &count) 360 362 { 361 - if let Some(parsed) = task::parse(&stack_item.title) { 362 - println!("{}\t{}", stack_item.id, parsed.content.trim()); 363 - } else { 364 - println!("{stack_item}"); 363 + match (task::parse(&stack_item.title), only_print_ids) { 364 + (None, false) => { 365 + println!("{stack_item}"); 366 + }, 367 + (Some(parsed), false) => { 368 + println!("{}\t{}", stack_item.id, parsed.content.trim()) 369 + }, 370 + (None, true) | (Some(_), true) => { 371 + println!("{}", stack_item.id) 372 + }, 365 373 } 366 374 } 367 375 Ok(())