···9494 },
95959696 /// Drops the task on the top of the stack and archives it.
9797- Drop,
9797+ Drop {
9898+ /// The [TSK-]ID of the task to drop.
9999+ #[command(flatten)]
100100+ task_id: TaskId,
101101+ },
9810299103 /// Moves the 3rd item on the stack to the front of the stack, shifting everything else down by
100104 /// one. If there are less than 3 tasks on the stack, has no effect.
···204208 Commands::Show { task_id } => command_show(dir, task_id),
205209 Commands::Edit { task_id } => command_edit(dir, task_id),
206210 Commands::Completion { shell } => command_completion(shell),
207207- Commands::Drop => command_drop(dir),
211211+ Commands::Drop { task_id } => command_drop(dir, task_id),
208212 Commands::Find { args, full_id } => command_find(dir, full_id, args),
209213 Commands::Rot => Workspace::from_path(dir).unwrap().rot(),
210214 Commands::Tor => Workspace::from_path(dir).unwrap().tor(),
211215 Commands::Prioritize { task_id } => command_prioritize(dir, task_id),
212216 Commands::Deprioritize { task_id } => command_deprioritize(dir, task_id),
213213-214217 };
215218 let result = var_name;
216219 match result {
···302305 Ok(())
303306}
304307305305-fn command_drop(dir: PathBuf) -> Result<()> {
306306- if let Some(id) = Workspace::from_path(dir)?.drop()? {
308308+fn command_drop(dir: PathBuf, task_id: TaskId) -> Result<()> {
309309+ if let Some(id) = Workspace::from_path(dir)?.drop(task_id.into())? {
307310 eprint!("Dropped ");
308311 println!("{id}");
309312 } else {
+9-10
src/workspace.rs
···217217 Ok(())
218218 }
219219220220- pub fn drop(&self) -> Result<Option<Id>> {
220220+ pub fn drop(&self, identifier: TaskIdentifier) -> Result<Option<Id>> {
221221+ let id = self.resolve(identifier)?;
221222 let mut stack = self.read_stack()?;
222222- if let Some(stack_item) = stack.pop() {
223223- let task_path = self
224224- .path
225225- .join("tasks")
226226- .join(format!("{}.tsk", stack_item.id));
227227- fs::remove_file(task_path)?;
223223+ let index = &stack.iter().map(|i| i.id).position(|i| i == id);
224224+ let task = if let Some(index) = index {
225225+ let prioritized_task = stack.remove(*index);
228226 stack.save()?;
229229- Ok(Some(stack_item.id))
227227+ prioritized_task.map(|t| t.id)
230228 } else {
231231- Ok(None)
232232- }
229229+ None
230230+ };
231231+ Ok(task)
233232 }
234233235234 pub fn search(