cli: let clap error out for us on jj restore -i <file>

This commit is contained in:
Martin von Zweigbergk 2022-04-06 23:20:34 -07:00 committed by Martin von Zweigbergk
parent 3d81d21ff5
commit 88e34d703e
2 changed files with 13 additions and 5 deletions

View file

@ -1284,6 +1284,7 @@ struct RestoreArgs {
/// Interactively choose which parts to restore
#[clap(long, short)]
interactive: bool,
#[clap(conflicts_with = "interactive")]
paths: Vec<String>,
}
@ -3299,11 +3300,6 @@ fn cmd_restore(
let repo = workspace_command.repo();
let tree_id;
if args.interactive {
if !args.paths.is_empty() {
return Err(UserError(
"restore with --interactive and path is not yet supported".to_string(),
));
}
let instructions = format!(
"\
You are restoring state from: {}

View file

@ -169,4 +169,16 @@ fn test_restore_interactive() {
@@ -1,0 +1,1 @@
+unrelated
"###);
// Combining paths with -i is not yet supported
std::fs::write(&edit_script, "").unwrap();
let stderr = test_env.jj_cmd_failure(&repo_path, &["restore", "-i", "file2"]);
insta::assert_snapshot!(stderr.replace("jj.exe", "jj"), @r###"
error: The argument '--interactive' cannot be used with '<PATHS>...'
USAGE:
jj restore --interactive
For more information try --help
"###);
}