···103103 /// task up.
104104 Tor,
105105106106- /// Reprioritizes an arbitrary task to the top of the stack.
107107- Reprioritize {
106106+ /// Prioritizes an arbitrary task to the top of the stack.
107107+ Prioritize {
108108 /// The [TSK-]ID to prioritize. If it exists, it is moved to the top of the stack.
109109+ #[command(flatten)]
110110+ task_id: TaskId,
111111+ },
112112+113113+ /// Deprioritizes a task to the bottom of the stack.
114114+ Deprioritize {
115115+ /// The [TSK-]ID to deprioritize. If it exists, it is moved to the bottom of the stack.
109116 #[command(flatten)]
110117 task_id: TaskId,
111118 },
···189196fn main() {
190197 let cli = Cli::parse();
191198 let dir = cli.dir.unwrap_or(default_dir());
192192- let result = match cli.command {
199199+ let var_name = match cli.command {
193200 Commands::Init => command_init(dir),
194201 Commands::Push { edit, body, title } => command_push(dir, edit, body, title),
195202 Commands::List { all, count } => command_list(dir, all, count),
···201208 Commands::Find { args, full_id } => command_find(dir, full_id, args),
202209 Commands::Rot => Workspace::from_path(dir).unwrap().rot(),
203210 Commands::Tor => Workspace::from_path(dir).unwrap().tor(),
204204- Commands::Reprioritize { task_id } => command_reprioritize(dir, task_id),
211211+ Commands::Prioritize { task_id } => command_prioritize(dir, task_id),
212212+ Commands::Deprioritize { task_id } => command_deprioritize(dir, task_id),
213213+205214 };
215215+ let result = var_name;
206216 match result {
207217 Ok(_) => exit(0),
208218 Err(e) => {
···319329 Ok(())
320330}
321331322322-fn command_reprioritize(dir: PathBuf, task_id: TaskId) -> Result<()> {
323323- Workspace::from_path(dir)?.reprioritize(task_id.into())
332332+fn command_prioritize(dir: PathBuf, task_id: TaskId) -> Result<()> {
333333+ Workspace::from_path(dir)?.prioritize(task_id.into())
334334+}
335335+336336+fn command_deprioritize(dir: PathBuf, task_id: TaskId) -> Result<()> {
337337+ Workspace::from_path(dir)?.deprioritize(task_id.into())
324338}
325339326340fn command_show(dir: PathBuf, task_id: TaskId) -> Result<()> {
···256256 }
257257 }
258258259259- pub fn reprioritize(&self, identifier: TaskIdentifier) -> Result<()> {
259259+ pub fn prioritize(&self, identifier: TaskIdentifier) -> Result<()> {
260260 let id = self.resolve(identifier)?;
261261 let mut stack = self.read_stack()?;
262262 let index = &stack.iter().map(|i| i.id).position(|i| i == id);
···264264 let prioritized_task = stack.remove(*index);
265265 // unwrap here is safe because we just searched for the index and know it exists
266266 stack.push(prioritized_task.unwrap());
267267+ stack.save()?;
268268+ }
269269+ Ok(())
270270+ }
271271+272272+ pub fn deprioritize(&self, identifier: TaskIdentifier) -> Result<()> {
273273+ let id = self.resolve(identifier)?;
274274+ let mut stack = self.read_stack()?;
275275+ let index = &stack.iter().map(|i| i.id).position(|i| i == id);
276276+ if let Some(index) = index {
277277+ let deprioritized_task = stack.remove(*index);
278278+ // unwrap here is safe because we just searched for the index and know it exists
279279+ stack.push_back(deprioritized_task.unwrap());
267280 stack.save()?;
268281 }
269282 Ok(())