Allow filtering reported tasks such that certain tags are omitted
This commit is contained in:
parent
29d1d5a2ef
commit
c6942468b2
3 changed files with 9 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -173,7 +173,7 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "day-reporter"
|
name = "day-reporter"
|
||||||
version = "1.3.1"
|
version = "1.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "day-reporter"
|
name = "day-reporter"
|
||||||
version = "1.3.1"
|
version = "1.4.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,11 @@ struct CliArgs {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
tags: Vec<String>,
|
tags: Vec<String>,
|
||||||
|
|
||||||
|
/// A list of tags to specifically omit from the results. Only todo list items WITHOUT these
|
||||||
|
/// tags will be included
|
||||||
|
#[arg(short, long)]
|
||||||
|
omit: Vec<String>,
|
||||||
|
|
||||||
/// Select the type of report to generate
|
/// Select the type of report to generate
|
||||||
#[arg(short, long, default_value_t = ReportTypes::default())]
|
#[arg(short, long, default_value_t = ReportTypes::default())]
|
||||||
#[clap(value_enum)]
|
#[clap(value_enum)]
|
||||||
|
|
@ -90,7 +95,8 @@ fn main() -> Result<()> {
|
||||||
ReportTypes::Cycle => Task::logbook_this_cycle(),
|
ReportTypes::Cycle => Task::logbook_this_cycle(),
|
||||||
}?;
|
}?;
|
||||||
let mut reported: Vec<Task> = tasks.into_iter().filter(|task| {
|
let mut reported: Vec<Task> = tasks.into_iter().filter(|task| {
|
||||||
args.tags.iter().all(|tag| task.has_tag(tag))
|
// Filter down to tasks with all selected tags and without any of the omitted tags
|
||||||
|
args.tags.iter().all(|tag| task.has_tag(tag)) && !args.omit.iter().any(|tag| task.has_tag(tag))
|
||||||
}).collect();
|
}).collect();
|
||||||
reported.sort_by(|a, b| {
|
reported.sort_by(|a, b| {
|
||||||
a.completion_date.cmp(&b.completion_date)
|
a.completion_date.cmp(&b.completion_date)
|
||||||
|
|
|
||||||
Reference in a new issue