add a 'ta undo' subcommand
This commit is contained in:
@@ -59,6 +59,7 @@ pub(crate) enum Subcommand {
|
||||
/// Basic operations without args
|
||||
Gc,
|
||||
Sync,
|
||||
Undo,
|
||||
}
|
||||
|
||||
impl Subcommand {
|
||||
@@ -72,6 +73,7 @@ impl Subcommand {
|
||||
Info::parse,
|
||||
Gc::parse,
|
||||
Sync::parse,
|
||||
Undo::parse,
|
||||
// This must come last since it accepts arbitrary report names
|
||||
Report::parse,
|
||||
)))(input)
|
||||
@@ -422,6 +424,29 @@ impl Sync {
|
||||
}
|
||||
}
|
||||
|
||||
struct Undo;
|
||||
|
||||
impl Undo {
|
||||
fn parse(input: ArgList) -> IResult<ArgList, Subcommand> {
|
||||
fn to_subcommand(_: &str) -> Result<Subcommand, ()> {
|
||||
Ok(Subcommand::Undo)
|
||||
}
|
||||
map_res(arg_matching(literal("undo")), to_subcommand)(input)
|
||||
}
|
||||
|
||||
fn get_usage(u: &mut usage::Usage) {
|
||||
u.subcommands.push(usage::Subcommand {
|
||||
name: "undo",
|
||||
syntax: "undo",
|
||||
summary: "Undo the latest change made on this replica",
|
||||
description: "
|
||||
Undo the latest change made on this replica.
|
||||
|
||||
Changes cannot be undone once they have been synchronized.",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
@@ -814,4 +839,13 @@ mod test {
|
||||
(&EMPTY[..], subcommand)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_undo() {
|
||||
let subcommand = Subcommand::Undo;
|
||||
assert_eq!(
|
||||
Subcommand::parse(argv!["undo"]).unwrap(),
|
||||
(&EMPTY[..], subcommand)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user