mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
cli: make branch command's --delete flag actually a flag, and require name arg
I had forgotten to make the `delete` argument a flag by giving it a name, so instead it conflicted with `name` argument, as tests discovered. While at it, I also made `name` required. It wasn't before because I originally had a single command for `jj branch` and `jj branches` and then I didn't think to make it required when I split them up.
This commit is contained in:
parent
10b2e25c30
commit
f85613cf66
1 changed files with 28 additions and 34 deletions
|
@ -730,8 +730,8 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
|
|||
.about("Update or delete branch")
|
||||
.arg(rev_arg())
|
||||
.arg(Arg::with_name("allow-backwards").long("allow-backwards"))
|
||||
.arg(Arg::with_name("delete"))
|
||||
.arg(Arg::with_name("name").index(1));
|
||||
.arg(Arg::with_name("delete").long("delete"))
|
||||
.arg(Arg::with_name("name").index(1).required(true));
|
||||
let branches_command = SubCommand::with_name("branches").about("List branches");
|
||||
let evolve_command =
|
||||
SubCommand::with_name("evolve").about("Resolve problems with the repo's meta-history");
|
||||
|
@ -2080,7 +2080,7 @@ fn cmd_branch(
|
|||
sub_matches: &ArgMatches,
|
||||
) -> Result<(), CommandError> {
|
||||
let mut repo_command = command.repo_helper(ui)?;
|
||||
if let Some(branch_name) = sub_matches.value_of("name") {
|
||||
let branch_name = sub_matches.value_of("name").unwrap();
|
||||
if sub_matches.is_present("delete") {
|
||||
let mut tx = repo_command.start_transaction(&format!("delete branch {}", branch_name));
|
||||
tx.mut_repo().remove_local_branch(branch_name);
|
||||
|
@ -2095,8 +2095,7 @@ fn cmd_branch(
|
|||
)
|
||||
{
|
||||
return Err(CommandError::UserError(
|
||||
"Use --allow-backwards to allow moving a branch backwards or sideways"
|
||||
.to_string(),
|
||||
"Use --allow-backwards to allow moving a branch backwards or sideways".to_string(),
|
||||
));
|
||||
}
|
||||
let mut tx = repo_command.start_transaction(&format!(
|
||||
|
@ -2110,11 +2109,6 @@ fn cmd_branch(
|
|||
);
|
||||
repo_command.finish_transaction(ui, tx)?;
|
||||
}
|
||||
} else {
|
||||
return Err(CommandError::UserError(
|
||||
"No branch name specified".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue