Implement 'ta import'

Tests include "TODO" notes for data not handled by TaskChampion,
including links to the associated GitHub issues.
This commit is contained in:
Dustin J. Mitchell
2022-01-05 03:12:55 +00:00
parent e2e0951c81
commit 63804b5652
7 changed files with 311 additions and 4 deletions

View File

@@ -59,6 +59,7 @@ pub(crate) enum Subcommand {
/// Basic operations without args
Gc,
Sync,
Import,
Undo,
}
@@ -73,6 +74,7 @@ impl Subcommand {
Info::parse,
Gc::parse,
Sync::parse,
Import::parse,
Undo::parse,
// This must come last since it accepts arbitrary report names
Report::parse,
@@ -88,6 +90,8 @@ impl Subcommand {
Info::get_usage(u);
Gc::get_usage(u);
Sync::get_usage(u);
Import::get_usage(u);
Undo::get_usage(u);
Report::get_usage(u);
}
}
@@ -424,6 +428,35 @@ impl Sync {
}
}
struct Import;
impl Import {
fn parse(input: ArgList) -> IResult<ArgList, Subcommand> {
fn to_subcommand(_: &str) -> Result<Subcommand, ()> {
Ok(Subcommand::Import)
}
map_res(arg_matching(literal("import")), to_subcommand)(input)
}
fn get_usage(u: &mut usage::Usage) {
u.subcommands.push(usage::Subcommand {
name: "import",
syntax: "import",
summary: "Import tasks",
description: "
Import tasks into this replica.
The tasks must be provided in the TaskWarrior JSON format on stdin. If tasks
in the import already exist, they are 'merged'.
Because TaskChampion lacks the information about the types of UDAs that is stored
in the TaskWarrior configuration, UDA values are imported as simple strings, in the
format they appear in the JSON export. This may cause undesirable results.
",
})
}
}
struct Undo;
impl Undo {