From 03bb726811a039304d9e05730f5112d8e7cc93f9 Mon Sep 17 00:00:00 2001 From: MNandor Date: Fri, 29 Oct 2021 17:47:05 +0300 Subject: [PATCH] Allow for custom tag instead of +next --- src/app.rs | 9 ++++++--- src/config.rs | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index fe617cd..8f5d59a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2014,6 +2014,9 @@ impl TaskwarriorTui { pub fn task_tag_next(&mut self) -> Result<(), String> { let app = TaskwarriorTui::new("next").unwrap(); + let tag_name = &self.config.uda_tag_next_name; + let ptag_name = format!("+{}", tag_name); + let ntag_name = format!("-{}", tag_name); if self.tasks.is_empty() { return Ok(()); } @@ -2022,10 +2025,10 @@ impl TaskwarriorTui { for task_uuid in &task_uuids { if let Some(task) = app.task_by_uuid(*task_uuid) { - let mut tag_to_set = "+next"; + let mut tag_to_set = &ptag_name; for tag in task.tags().unwrap() { - if tag == "next" { - tag_to_set = "-next"; + if tag == tag_name { + tag_to_set = &ntag_name; } } diff --git a/src/config.rs b/src/config.rs index 3b18249..cf02a4e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,6 +65,7 @@ pub struct Config { pub uda_shortcuts: Vec, pub uda_background_process: String, pub uda_background_process_period: usize, + pub uda_tag_next_name: String, pub uda_task_report_prompt_on_delete: bool, pub uda_task_report_prompt_on_done: bool, } @@ -111,6 +112,7 @@ impl Config { let uda_style_context_active = uda_style_context_active.unwrap_or_default(); let uda_style_report_completion_pane = uda_style_report_completion_pane.unwrap_or_else(|| Style::default().bg(Color::Rgb(223, 223, 223))); + let uda_tag_next_name = Self::get_uda_tag_next_name(data); let uda_task_report_prompt_on_delete = Self::get_uda_task_report_prompt_on_delete(data); let uda_task_report_prompt_on_done = Self::get_uda_task_report_prompt_on_done(data); @@ -145,6 +147,7 @@ impl Config { uda_shortcuts, uda_background_process, uda_background_process_period, + uda_tag_next_name, uda_task_report_prompt_on_delete, uda_task_report_prompt_on_done, }) @@ -542,6 +545,14 @@ impl Config { .parse::() .unwrap_or(4) } + + fn get_uda_tag_next_name(data: &str) -> String { + let tag_name = Self::get_config("uda.taskwarrior-tui.next-tag.name", data); + match tag_name { + None => "next".to_string(), + Some(tag_name) => format!("{}", tag_name), + } + } } #[cfg(test)]