ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: make dummy revert command accept any arguments

Before, `jj revert qq` would say that `qq` is an extraneous argument.
Now, it says "Error: No such subcommand: revert".
This commit is contained in:
Ilya Grigoriev 2023-11-17 19:17:16 -08:00
parent 1c5d0e0d63
commit af81cbd942

View file

@ -119,7 +119,7 @@ enum Commands {
hide = true,
help_template = "Not a real subcommand; consider `jj backout` or `jj restore`"
)]
Revert,
Revert(DummyCommandArgs),
#[command(hide = true)]
// TODO: Flesh out.
Run(run::RunArgs),
@ -140,6 +140,13 @@ enum Commands {
Workspace(workspace::WorkspaceCommands),
}
/// A dummy command that accepts any arguments
#[derive(clap::Args, Clone, Debug)]
struct DummyCommandArgs {
#[arg(trailing_var_arg = true, allow_hyphen_values = true, hide = true)]
_args: Vec<String>,
}
fn make_branch_term(branch_names: &[impl fmt::Display]) -> String {
match branch_names {
[branch_name] => format!("branch {}", branch_name),
@ -181,7 +188,7 @@ pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), Co
Commands::Squash(sub_args) => squash::cmd_squash(ui, command_helper, sub_args),
Commands::Unsquash(sub_args) => unsquash::cmd_unsquash(ui, command_helper, sub_args),
Commands::Restore(sub_args) => restore::cmd_restore(ui, command_helper, sub_args),
Commands::Revert => revert(),
Commands::Revert(_args) => revert(),
Commands::Run(sub_args) => run::cmd_run(ui, command_helper, sub_args),
Commands::Diffedit(sub_args) => diffedit::cmd_diffedit(ui, command_helper, sub_args),
Commands::Split(sub_args) => split::cmd_split(ui, command_helper, sub_args),