mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Add +next tag shortcut on \'n\'
This commit is contained in:
parent
c206801786
commit
d09f65b2b1
2 changed files with 48 additions and 0 deletions
43
src/app.rs
43
src/app.rs
|
@ -2012,6 +2012,41 @@ impl TaskwarriorTui {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn task_tag_next(&mut self) -> Result<(), String> {
|
||||||
|
|
||||||
|
let app = TaskwarriorTui::new("next").unwrap();
|
||||||
|
if self.tasks.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let task_uuids = self.selected_task_uuids();
|
||||||
|
|
||||||
|
for task_uuid in &task_uuids {
|
||||||
|
if let Some(task) = app.task_by_uuid(*task_uuid) {
|
||||||
|
let mut tag_to_set = "+next";
|
||||||
|
for tag in task.tags().unwrap() {
|
||||||
|
if tag == "next" {
|
||||||
|
tag_to_set = "-next";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = Command::new("task").arg(task_uuid.to_string()).arg("modify").arg(tag_to_set).output();
|
||||||
|
if output.is_err() {
|
||||||
|
return Err(format!("Error running `task modify {}` for task `{}`.", tag_to_set, task_uuid,));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if task_uuids.len() == 1 {
|
||||||
|
if let Some(uuid) = task_uuids.get(0) {
|
||||||
|
self.current_selection_uuid = Some(*uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn task_delete(&mut self) -> Result<(), String> {
|
pub fn task_delete(&mut self) -> Result<(), String> {
|
||||||
if self.tasks.is_empty() {
|
if self.tasks.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -2430,6 +2465,14 @@ impl TaskwarriorTui {
|
||||||
self.error = e;
|
self.error = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if input == self.keyconfig.tag_next {
|
||||||
|
match self.task_tag_next() {
|
||||||
|
Ok(_) => self.update(true)?,
|
||||||
|
Err(e) => {
|
||||||
|
self.mode = Mode::Tasks(Action::Error);
|
||||||
|
self.error = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if input == self.keyconfig.edit {
|
} else if input == self.keyconfig.edit {
|
||||||
match self.task_edit() {
|
match self.task_edit() {
|
||||||
Ok(_) => self.update(true)?,
|
Ok(_) => self.update(true)?,
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub struct KeyConfig {
|
||||||
pub delete: Key,
|
pub delete: Key,
|
||||||
pub done: Key,
|
pub done: Key,
|
||||||
pub start_stop: Key,
|
pub start_stop: Key,
|
||||||
|
pub tag_next: Key,
|
||||||
pub select: Key,
|
pub select: Key,
|
||||||
pub select_all: Key,
|
pub select_all: Key,
|
||||||
pub undo: Key,
|
pub undo: Key,
|
||||||
|
@ -60,6 +61,7 @@ impl Default for KeyConfig {
|
||||||
delete: Key::Char('x'),
|
delete: Key::Char('x'),
|
||||||
done: Key::Char('d'),
|
done: Key::Char('d'),
|
||||||
start_stop: Key::Char('s'),
|
start_stop: Key::Char('s'),
|
||||||
|
tag_next: Key::Char('n'),
|
||||||
select: Key::Char('v'),
|
select: Key::Char('v'),
|
||||||
select_all: Key::Char('V'),
|
select_all: Key::Char('V'),
|
||||||
undo: Key::Char('u'),
|
undo: Key::Char('u'),
|
||||||
|
@ -108,6 +110,7 @@ impl KeyConfig {
|
||||||
let delete = Self::get_config("uda.taskwarrior-tui.keyconfig.delete", data);
|
let delete = Self::get_config("uda.taskwarrior-tui.keyconfig.delete", data);
|
||||||
let done = Self::get_config("uda.taskwarrior-tui.keyconfig.done", data);
|
let done = Self::get_config("uda.taskwarrior-tui.keyconfig.done", data);
|
||||||
let start_stop = Self::get_config("uda.taskwarrior-tui.keyconfig.start-stop", data);
|
let start_stop = Self::get_config("uda.taskwarrior-tui.keyconfig.start-stop", data);
|
||||||
|
let tag_next = Self::get_config("uda.taskwarrior-tui.keyconfig.tag-next", data);
|
||||||
let select = Self::get_config("uda.taskwarrior-tui.keyconfig.select", data);
|
let select = Self::get_config("uda.taskwarrior-tui.keyconfig.select", data);
|
||||||
let select_all = Self::get_config("uda.taskwarrior-tui.keyconfig.select-all", data);
|
let select_all = Self::get_config("uda.taskwarrior-tui.keyconfig.select-all", data);
|
||||||
let undo = Self::get_config("uda.taskwarrior-tui.keyconfig.undo", data);
|
let undo = Self::get_config("uda.taskwarrior-tui.keyconfig.undo", data);
|
||||||
|
@ -134,6 +137,7 @@ impl KeyConfig {
|
||||||
self.delete = delete.unwrap_or(self.delete);
|
self.delete = delete.unwrap_or(self.delete);
|
||||||
self.done = done.unwrap_or(self.done);
|
self.done = done.unwrap_or(self.done);
|
||||||
self.start_stop = start_stop.unwrap_or(self.start_stop);
|
self.start_stop = start_stop.unwrap_or(self.start_stop);
|
||||||
|
self.tag_next = tag_next.unwrap_or(self.tag_next);
|
||||||
self.select = select.unwrap_or(self.select);
|
self.select = select.unwrap_or(self.select);
|
||||||
self.select_all = select_all.unwrap_or(self.select_all);
|
self.select_all = select_all.unwrap_or(self.select_all);
|
||||||
self.undo = undo.unwrap_or(self.undo);
|
self.undo = undo.unwrap_or(self.undo);
|
||||||
|
@ -167,6 +171,7 @@ impl KeyConfig {
|
||||||
&self.select,
|
&self.select,
|
||||||
&self.select_all,
|
&self.select_all,
|
||||||
&self.start_stop,
|
&self.start_stop,
|
||||||
|
&self.tag_next,
|
||||||
&self.undo,
|
&self.undo,
|
||||||
&self.edit,
|
&self.edit,
|
||||||
&self.modify,
|
&self.modify,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue