mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Support all virtual tags
This commit is contained in:
parent
4f82fb835e
commit
1e541cdb3f
1 changed files with 46 additions and 18 deletions
64
src/app.rs
64
src/app.rs
|
@ -29,7 +29,6 @@ use rustyline::error::ReadlineError;
|
||||||
use rustyline::line_buffer::LineBuffer;
|
use rustyline::line_buffer::LineBuffer;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
|
|
||||||
|
|
||||||
const MAX_LINE: usize = 4096;
|
const MAX_LINE: usize = 4096;
|
||||||
|
|
||||||
pub fn cmp(t1: &Task, t2: &Task) -> Ordering {
|
pub fn cmp(t1: &Task, t2: &Task) -> Ordering {
|
||||||
|
@ -605,6 +604,40 @@ impl TTApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_string_attribute(&self, attribute: &str, task: &Task) -> String {
|
pub fn get_string_attribute(&self, attribute: &str, task: &Task) -> String {
|
||||||
|
let tags = vec![
|
||||||
|
"PROJECT",
|
||||||
|
"BLOCKED",
|
||||||
|
"UNBLOCKED",
|
||||||
|
"BLOCKING",
|
||||||
|
"DUE",
|
||||||
|
"DUETODAY",
|
||||||
|
"TODAY",
|
||||||
|
"OVERDUE",
|
||||||
|
"WEEK",
|
||||||
|
"MONTH",
|
||||||
|
"QUARTER",
|
||||||
|
"YEAR",
|
||||||
|
"ACTIVE",
|
||||||
|
"SCHEDULED",
|
||||||
|
"PARENT",
|
||||||
|
"CHILD",
|
||||||
|
"UNTIL",
|
||||||
|
"WAITING",
|
||||||
|
"ANNOTATED",
|
||||||
|
"READY",
|
||||||
|
"YESTERDAY",
|
||||||
|
"TOMORROW",
|
||||||
|
"TAGGED",
|
||||||
|
"PENDING",
|
||||||
|
"COMPLETED",
|
||||||
|
"DELETED",
|
||||||
|
"UDA",
|
||||||
|
"ORPHAN",
|
||||||
|
"PRIORITY",
|
||||||
|
"PROJECT",
|
||||||
|
"LATEST",
|
||||||
|
];
|
||||||
|
|
||||||
match attribute {
|
match attribute {
|
||||||
"id" => task.id().unwrap_or_default().to_string(),
|
"id" => task.id().unwrap_or_default().to_string(),
|
||||||
"due.relative" => match task.due() {
|
"due.relative" => match task.due() {
|
||||||
|
@ -626,9 +659,7 @@ impl TTApp {
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
"project" => match task.project() {
|
"project" => match task.project() {
|
||||||
Some(p) => {
|
Some(p) => format!("{}", p).to_string(),
|
||||||
format!("{}", p).to_string()
|
|
||||||
},
|
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
"depends.count" => match task.depends() {
|
"depends.count" => match task.depends() {
|
||||||
|
@ -638,38 +669,35 @@ impl TTApp {
|
||||||
} else {
|
} else {
|
||||||
format!("{}", v.len()).to_string()
|
format!("{}", v.len()).to_string()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
"tags.count" => match task.tags() {
|
"tags.count" => match task.tags() {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
let t = v.iter()
|
let t = v
|
||||||
.filter(|t| t.as_str() != "PENDING")
|
.into_iter()
|
||||||
.filter(|t| t.as_str() != "ANNOTATED")
|
.filter(|t| !tags.contains(&t.as_str()))
|
||||||
.filter(|t| t.as_str() != "TAGGED")
|
|
||||||
.filter(|t| t.as_str() != "PROJECT")
|
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<String>>().len();
|
.collect::<Vec<String>>()
|
||||||
|
.len();
|
||||||
if t == 0 {
|
if t == 0 {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("{}", t).to_string()
|
format!("{}", t).to_string()
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
"tags" => match task.tags() {
|
"tags" => match task.tags() {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
let t = v.iter()
|
let t = v
|
||||||
.filter(|t| t.as_str() != "PENDING")
|
.iter()
|
||||||
.filter(|t| t.as_str() != "ANNOTATED")
|
.filter(|t| !tags.contains(&t.as_str()))
|
||||||
.filter(|t| t.as_str() != "TAGGED")
|
|
||||||
.filter(|t| t.as_str() != "PROJECT")
|
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join(",");
|
.join(",");
|
||||||
format!("{}", t).to_string()
|
format!("{}", t).to_string()
|
||||||
},
|
}
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
},
|
},
|
||||||
"description.count" => task.description().to_string(),
|
"description.count" => task.description().to_string(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue