···103 /// task up.
104 Tor,
105106- /// Reprioritizes an arbitrary task to the top of the stack.
107- Reprioritize {
108 /// The [TSK-]ID to prioritize. If it exists, it is moved to the top of the stack.
0000000109 #[command(flatten)]
110 task_id: TaskId,
111 },
···189fn main() {
190 let cli = Cli::parse();
191 let dir = cli.dir.unwrap_or(default_dir());
192- let result = match cli.command {
193 Commands::Init => command_init(dir),
194 Commands::Push { edit, body, title } => command_push(dir, edit, body, title),
195 Commands::List { all, count } => command_list(dir, all, count),
···201 Commands::Find { args, full_id } => command_find(dir, full_id, args),
202 Commands::Rot => Workspace::from_path(dir).unwrap().rot(),
203 Commands::Tor => Workspace::from_path(dir).unwrap().tor(),
204- Commands::Reprioritize { task_id } => command_reprioritize(dir, task_id),
00205 };
0206 match result {
207 Ok(_) => exit(0),
208 Err(e) => {
···319 Ok(())
320}
321322-fn command_reprioritize(dir: PathBuf, task_id: TaskId) -> Result<()> {
323- Workspace::from_path(dir)?.reprioritize(task_id.into())
0000324}
325326fn command_show(dir: PathBuf, task_id: TaskId) -> Result<()> {
···103 /// task up.
104 Tor,
105106+ /// Prioritizes an arbitrary task to the top of the stack.
107+ Prioritize {
108 /// The [TSK-]ID to prioritize. If it exists, it is moved to the top of the stack.
109+ #[command(flatten)]
110+ task_id: TaskId,
111+ },
112+113+ /// Deprioritizes a task to the bottom of the stack.
114+ Deprioritize {
115+ /// The [TSK-]ID to deprioritize. If it exists, it is moved to the bottom of the stack.
116 #[command(flatten)]
117 task_id: TaskId,
118 },
···196fn main() {
197 let cli = Cli::parse();
198 let dir = cli.dir.unwrap_or(default_dir());
199+ let var_name = match cli.command {
200 Commands::Init => command_init(dir),
201 Commands::Push { edit, body, title } => command_push(dir, edit, body, title),
202 Commands::List { all, count } => command_list(dir, all, count),
···208 Commands::Find { args, full_id } => command_find(dir, full_id, args),
209 Commands::Rot => Workspace::from_path(dir).unwrap().rot(),
210 Commands::Tor => Workspace::from_path(dir).unwrap().tor(),
211+ Commands::Prioritize { task_id } => command_prioritize(dir, task_id),
212+ Commands::Deprioritize { task_id } => command_deprioritize(dir, task_id),
213+214 };
215+ let result = var_name;
216 match result {
217 Ok(_) => exit(0),
218 Err(e) => {
···329 Ok(())
330}
331332+fn command_prioritize(dir: PathBuf, task_id: TaskId) -> Result<()> {
333+ Workspace::from_path(dir)?.prioritize(task_id.into())
334+}
335+336+fn command_deprioritize(dir: PathBuf, task_id: TaskId) -> Result<()> {
337+ Workspace::from_path(dir)?.deprioritize(task_id.into())
338}
339340fn command_show(dir: PathBuf, task_id: TaskId) -> Result<()> {
···256 }
257 }
258259- pub fn reprioritize(&self, identifier: TaskIdentifier) -> Result<()> {
260 let id = self.resolve(identifier)?;
261 let mut stack = self.read_stack()?;
262 let index = &stack.iter().map(|i| i.id).position(|i| i == id);
···264 let prioritized_task = stack.remove(*index);
265 // unwrap here is safe because we just searched for the index and know it exists
266 stack.push(prioritized_task.unwrap());
0000000000000267 stack.save()?;
268 }
269 Ok(())
···256 }
257 }
258259+ pub fn prioritize(&self, identifier: TaskIdentifier) -> Result<()> {
260 let id = self.resolve(identifier)?;
261 let mut stack = self.read_stack()?;
262 let index = &stack.iter().map(|i| i.id).position(|i| i == id);
···264 let prioritized_task = stack.remove(*index);
265 // unwrap here is safe because we just searched for the index and know it exists
266 stack.push(prioritized_task.unwrap());
267+ stack.save()?;
268+ }
269+ Ok(())
270+ }
271+272+ pub fn deprioritize(&self, identifier: TaskIdentifier) -> Result<()> {
273+ let id = self.resolve(identifier)?;
274+ let mut stack = self.read_stack()?;
275+ let index = &stack.iter().map(|i| i.id).position(|i| i == id);
276+ if let Some(index) = index {
277+ let deprioritized_task = stack.remove(*index);
278+ // unwrap here is safe because we just searched for the index and know it exists
279+ stack.push_back(deprioritized_task.unwrap());
280 stack.save()?;
281 }
282 Ok(())