diff --git a/src/commands.rs b/src/commands.rs index 38a53fb5f..12bb676cb 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1284,6 +1284,7 @@ struct RestoreArgs { /// Interactively choose which parts to restore #[clap(long, short)] interactive: bool, + #[clap(conflicts_with = "interactive")] paths: Vec, } @@ -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: {} diff --git a/tests/test_restore_command.rs b/tests/test_restore_command.rs index 15c2fa0ca..dd48f7330 100644 --- a/tests/test_restore_command.rs +++ b/tests/test_restore_command.rs @@ -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 '...' + + USAGE: + jj restore --interactive + + For more information try --help + "###); }