A file-based task manager
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow drop to work on any task

+17 -15
+8 -5
src/main.rs
··· 94 94 }, 95 95 96 96 /// Drops the task on the top of the stack and archives it. 97 - Drop, 97 + Drop { 98 + /// The [TSK-]ID of the task to drop. 99 + #[command(flatten)] 100 + task_id: TaskId, 101 + }, 98 102 99 103 /// Moves the 3rd item on the stack to the front of the stack, shifting everything else down by 100 104 /// one. If there are less than 3 tasks on the stack, has no effect. ··· 204 208 Commands::Show { task_id } => command_show(dir, task_id), 205 209 Commands::Edit { task_id } => command_edit(dir, task_id), 206 210 Commands::Completion { shell } => command_completion(shell), 207 - Commands::Drop => command_drop(dir), 211 + Commands::Drop { task_id } => command_drop(dir, task_id), 208 212 Commands::Find { args, full_id } => command_find(dir, full_id, args), 209 213 Commands::Rot => Workspace::from_path(dir).unwrap().rot(), 210 214 Commands::Tor => Workspace::from_path(dir).unwrap().tor(), 211 215 Commands::Prioritize { task_id } => command_prioritize(dir, task_id), 212 216 Commands::Deprioritize { task_id } => command_deprioritize(dir, task_id), 213 - 214 217 }; 215 218 let result = var_name; 216 219 match result { ··· 302 305 Ok(()) 303 306 } 304 307 305 - fn command_drop(dir: PathBuf) -> Result<()> { 306 - if let Some(id) = Workspace::from_path(dir)?.drop()? { 308 + fn command_drop(dir: PathBuf, task_id: TaskId) -> Result<()> { 309 + if let Some(id) = Workspace::from_path(dir)?.drop(task_id.into())? { 307 310 eprint!("Dropped "); 308 311 println!("{id}"); 309 312 } else {
+9 -10
src/workspace.rs
··· 217 217 Ok(()) 218 218 } 219 219 220 - pub fn drop(&self) -> Result<Option<Id>> { 220 + pub fn drop(&self, identifier: TaskIdentifier) -> Result<Option<Id>> { 221 + let id = self.resolve(identifier)?; 221 222 let mut stack = self.read_stack()?; 222 - if let Some(stack_item) = stack.pop() { 223 - let task_path = self 224 - .path 225 - .join("tasks") 226 - .join(format!("{}.tsk", stack_item.id)); 227 - fs::remove_file(task_path)?; 223 + let index = &stack.iter().map(|i| i.id).position(|i| i == id); 224 + let task = if let Some(index) = index { 225 + let prioritized_task = stack.remove(*index); 228 226 stack.save()?; 229 - Ok(Some(stack_item.id)) 227 + prioritized_task.map(|t| t.id) 230 228 } else { 231 - Ok(None) 232 - } 229 + None 230 + }; 231 + Ok(task) 233 232 } 234 233 235 234 pub fn search(