mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
24 lines
517 B
Rust
24 lines
517 B
Rust
use task_hookrs::task::Task;
|
|
|
|
pub trait TaskwarriorTuiTask {
|
|
fn add_tag(&mut self, tag: String);
|
|
|
|
fn remove_tag(&mut self, tag: &str);
|
|
}
|
|
|
|
impl TaskwarriorTuiTask for Task {
|
|
fn add_tag(&mut self, tag: String) {
|
|
match self.tags_mut() {
|
|
Some(t) => t.push(tag),
|
|
None => self.set_tags(Some(vec![tag])),
|
|
}
|
|
}
|
|
|
|
fn remove_tag(&mut self, tag: &str) {
|
|
if let Some(t) = self.tags_mut() {
|
|
if let Some(index) = t.iter().position(|x| *x == tag) {
|
|
t.remove(index);
|
|
}
|
|
}
|
|
}
|
|
}
|