Skip to content

Commit

Permalink
cli: make dummy revert command accept any arguments
Browse files Browse the repository at this point in the history
Before, `jj revert qq` would say that `qq` is an extraneous argument.
Now, it says "Error: No such subcommand: revert".
  • Loading branch information
ilyagr committed Nov 18, 2023
1 parent 1c5d0e0 commit af81cbd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit af81cbd

Please sign in to comment.