add a 'ta delete' subcommand

This commit is contained in:
Dustin J. Mitchell 2022-03-06 22:28:06 +00:00
parent 3cdc13aa37
commit 97bd2addc9
No known key found for this signature in database

View file

@ -218,6 +218,7 @@ impl Modify {
"start" => modification.active = Some(true), "start" => modification.active = Some(true),
"stop" => modification.active = Some(false), "stop" => modification.active = Some(false),
"done" => modification.status = Some(Status::Completed), "done" => modification.status = Some(Status::Completed),
"delete" => modification.status = Some(Status::Deleted),
"annotate" => { "annotate" => {
// what would be parsed as a description is, here, used as the annotation // what would be parsed as a description is, here, used as the annotation
if let DescriptionMod::Set(s) = modification.description { if let DescriptionMod::Set(s) = modification.description {
@ -243,6 +244,7 @@ impl Modify {
arg_matching(literal("start")), arg_matching(literal("start")),
arg_matching(literal("stop")), arg_matching(literal("stop")),
arg_matching(literal("done")), arg_matching(literal("done")),
arg_matching(literal("delete")),
arg_matching(literal("annotate")), arg_matching(literal("annotate")),
)), )),
Modification::parse, Modification::parse,
@ -297,10 +299,19 @@ impl Modify {
Mark all tasks matching the required filter as completed, additionally applying any given Mark all tasks matching the required filter as completed, additionally applying any given
modifications.", modifications.",
}); });
u.subcommands.push(usage::Subcommand {
name: "delete",
syntax: "<filter> delete [modification]",
summary: "Mark tasks as deleted",
description: "
Mark all tasks matching the required filter as deleted, additionally applying any given
modifications. Deleted tasks remain until they are expired in a 'ta gc' operation at
least six months after their last modification.",
});
u.subcommands.push(usage::Subcommand { u.subcommands.push(usage::Subcommand {
name: "annotate", name: "annotate",
syntax: "<filter> annotate [modification]", syntax: "<filter> annotate [modification]",
summary: "Mark tasks as completed", summary: "Annotate a task",
description: " description: "
Add an annotation to all tasks matching the required filter.", Add an annotation to all tasks matching the required filter.",
}); });
@ -761,6 +772,23 @@ mod test {
); );
} }
#[test]
fn test_delete() {
let subcommand = Subcommand::Modify {
filter: Filter {
conditions: vec![Condition::IdList(vec![TaskId::WorkingSetId(123)])],
},
modification: Modification {
status: Some(Status::Deleted),
..Default::default()
},
};
assert_eq!(
Subcommand::parse(argv!["123", "delete"]).unwrap(),
(&EMPTY[..], subcommand)
);
}
#[test] #[test]
fn test_annotate() { fn test_annotate() {
let subcommand = Subcommand::Modify { let subcommand = Subcommand::Modify {