forked from mirrors/jj
commands: rename various *matches
variables to *args
I think the `*matches` names are leftovers from before we used clap's Derive API.
This commit is contained in:
parent
3618eaf570
commit
4aad7f86ac
6 changed files with 49 additions and 67 deletions
|
@ -130,65 +130,57 @@ pub(crate) fn cmd_bench(
|
|||
subcommand: &BenchCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
BenchCommands::CommonAncestors(command_matches) => {
|
||||
BenchCommands::CommonAncestors(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let commit1 = workspace_command.resolve_single_rev(&command_matches.revision1, ui)?;
|
||||
let commit2 = workspace_command.resolve_single_rev(&command_matches.revision2, ui)?;
|
||||
let commit1 = workspace_command.resolve_single_rev(&args.revision1, ui)?;
|
||||
let commit2 = workspace_command.resolve_single_rev(&args.revision2, ui)?;
|
||||
let index = workspace_command.repo().index();
|
||||
let routine =
|
||||
|| index.common_ancestors(&[commit1.id().clone()], &[commit2.id().clone()]);
|
||||
run_bench(
|
||||
ui,
|
||||
&format!(
|
||||
"commonancestors-{}-{}",
|
||||
&command_matches.revision1, &command_matches.revision2
|
||||
),
|
||||
&command_matches.criterion,
|
||||
&format!("commonancestors-{}-{}", &args.revision1, &args.revision2),
|
||||
&args.criterion,
|
||||
routine,
|
||||
)?;
|
||||
}
|
||||
BenchCommands::IsAncestor(command_matches) => {
|
||||
BenchCommands::IsAncestor(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let ancestor_commit =
|
||||
workspace_command.resolve_single_rev(&command_matches.ancestor, ui)?;
|
||||
let descendant_commit =
|
||||
workspace_command.resolve_single_rev(&command_matches.descendant, ui)?;
|
||||
let ancestor_commit = workspace_command.resolve_single_rev(&args.ancestor, ui)?;
|
||||
let descendant_commit = workspace_command.resolve_single_rev(&args.descendant, ui)?;
|
||||
let index = workspace_command.repo().index();
|
||||
let routine = || index.is_ancestor(ancestor_commit.id(), descendant_commit.id());
|
||||
run_bench(
|
||||
ui,
|
||||
&format!(
|
||||
"isancestor-{}-{}",
|
||||
&command_matches.ancestor, &command_matches.descendant
|
||||
),
|
||||
&command_matches.criterion,
|
||||
&format!("isancestor-{}-{}", &args.ancestor, &args.descendant),
|
||||
&args.criterion,
|
||||
routine,
|
||||
)?;
|
||||
}
|
||||
BenchCommands::ResolvePrefix(command_matches) => {
|
||||
BenchCommands::ResolvePrefix(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let prefix = HexPrefix::new(&command_matches.prefix).unwrap();
|
||||
let prefix = HexPrefix::new(&args.prefix).unwrap();
|
||||
let index = workspace_command.repo().index();
|
||||
let routine = || index.resolve_prefix(&prefix);
|
||||
run_bench(
|
||||
ui,
|
||||
&format!("resolveprefix-{}", prefix.hex()),
|
||||
&command_matches.criterion,
|
||||
&args.criterion,
|
||||
routine,
|
||||
)?;
|
||||
}
|
||||
BenchCommands::Revset(command_matches) => {
|
||||
BenchCommands::Revset(args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let revsets = if let Some(file_path) = &command_matches.file {
|
||||
let revsets = if let Some(file_path) = &args.file {
|
||||
std::fs::read_to_string(command.cwd().join(file_path))?
|
||||
.lines()
|
||||
.map(|line| line.trim().to_owned())
|
||||
.filter(|line| !line.is_empty() && !line.starts_with('#'))
|
||||
.collect()
|
||||
} else {
|
||||
command_matches.revisions.clone()
|
||||
args.revisions.clone()
|
||||
};
|
||||
let mut criterion = new_criterion(ui, &command_matches.criterion);
|
||||
let mut criterion = new_criterion(ui, &args.criterion);
|
||||
let mut group = criterion.benchmark_group("revsets");
|
||||
for revset in &revsets {
|
||||
bench_revset(ui, command, &workspace_command, &mut group, revset)?;
|
||||
|
|
|
@ -113,7 +113,7 @@ pub fn cmd_debug(
|
|||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
DebugCommands::Revset(args) => cmd_debug_revset(ui, command, args)?,
|
||||
DebugCommands::WorkingCopy(_wc_matches) => {
|
||||
DebugCommands::WorkingCopy(_wc_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let wc = check_local_disk_wc(workspace_command.working_copy().as_any())?;
|
||||
writeln!(ui.stdout(), "Current operation: {:?}", wc.operation_id())?;
|
||||
|
@ -129,11 +129,11 @@ pub fn cmd_debug(
|
|||
)?;
|
||||
}
|
||||
}
|
||||
DebugCommands::Template(template_matches) => {
|
||||
let node = template_parser::parse_template(&template_matches.template)?;
|
||||
DebugCommands::Template(template_args) => {
|
||||
let node = template_parser::parse_template(&template_args.template)?;
|
||||
writeln!(ui.stdout(), "{node:#?}")?;
|
||||
}
|
||||
DebugCommands::Index(_index_matches) => {
|
||||
DebugCommands::Index(_index_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let repo = workspace_command.repo();
|
||||
let index_impl: Option<&ReadonlyIndexWrapper> =
|
||||
|
@ -162,7 +162,7 @@ pub fn cmd_debug(
|
|||
)));
|
||||
}
|
||||
}
|
||||
DebugCommands::ReIndex(_reindex_matches) => {
|
||||
DebugCommands::ReIndex(_reindex_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let repo = workspace_command.repo();
|
||||
let default_index_store: Option<&DefaultIndexStore> =
|
||||
|
|
|
@ -1150,25 +1150,23 @@ pub fn cmd_git(
|
|||
subcommand: &GitCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
GitCommands::Fetch(command_matches) => cmd_git_fetch(ui, command, command_matches),
|
||||
GitCommands::Clone(command_matches) => cmd_git_clone(ui, command, command_matches),
|
||||
GitCommands::Remote(GitRemoteCommands::Add(command_matches)) => {
|
||||
cmd_git_remote_add(ui, command, command_matches)
|
||||
GitCommands::Fetch(args) => cmd_git_fetch(ui, command, args),
|
||||
GitCommands::Clone(args) => cmd_git_clone(ui, command, args),
|
||||
GitCommands::Remote(GitRemoteCommands::Add(args)) => cmd_git_remote_add(ui, command, args),
|
||||
GitCommands::Remote(GitRemoteCommands::Remove(args)) => {
|
||||
cmd_git_remote_remove(ui, command, args)
|
||||
}
|
||||
GitCommands::Remote(GitRemoteCommands::Remove(command_matches)) => {
|
||||
cmd_git_remote_remove(ui, command, command_matches)
|
||||
GitCommands::Remote(GitRemoteCommands::Rename(args)) => {
|
||||
cmd_git_remote_rename(ui, command, args)
|
||||
}
|
||||
GitCommands::Remote(GitRemoteCommands::Rename(command_matches)) => {
|
||||
cmd_git_remote_rename(ui, command, command_matches)
|
||||
GitCommands::Remote(GitRemoteCommands::List(args)) => {
|
||||
cmd_git_remote_list(ui, command, args)
|
||||
}
|
||||
GitCommands::Remote(GitRemoteCommands::List(command_matches)) => {
|
||||
cmd_git_remote_list(ui, command, command_matches)
|
||||
}
|
||||
GitCommands::Push(command_matches) => cmd_git_push(ui, command, command_matches),
|
||||
GitCommands::Import(command_matches) => cmd_git_import(ui, command, command_matches),
|
||||
GitCommands::Export(command_matches) => cmd_git_export(ui, command, command_matches),
|
||||
GitCommands::Submodule(GitSubmoduleCommands::PrintGitmodules(command_matches)) => {
|
||||
cmd_git_submodule_print_gitmodules(ui, command, command_matches)
|
||||
GitCommands::Push(args) => cmd_git_push(ui, command, args),
|
||||
GitCommands::Import(args) => cmd_git_import(ui, command, args),
|
||||
GitCommands::Export(args) => cmd_git_export(ui, command, args),
|
||||
GitCommands::Submodule(GitSubmoduleCommands::PrintGitmodules(args)) => {
|
||||
cmd_git_submodule_print_gitmodules(ui, command, args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,8 +243,8 @@ pub fn cmd_operation(
|
|||
subcommand: &OperationCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
OperationCommands::Log(command_matches) => cmd_op_log(ui, command, command_matches),
|
||||
OperationCommands::Restore(command_matches) => cmd_op_restore(ui, command, command_matches),
|
||||
OperationCommands::Undo(command_matches) => cmd_op_undo(ui, command, command_matches),
|
||||
OperationCommands::Log(args) => cmd_op_log(ui, command, args),
|
||||
OperationCommands::Restore(args) => cmd_op_restore(ui, command, args),
|
||||
OperationCommands::Undo(args) => cmd_op_undo(ui, command, args),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ pub(crate) fn cmd_util(
|
|||
subcommand: &UtilCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
UtilCommands::Completion(completion_matches) => {
|
||||
UtilCommands::Completion(completion_args) => {
|
||||
let mut app = command.app().clone();
|
||||
let mut buf = vec![];
|
||||
let shell = if completion_matches.zsh {
|
||||
let shell = if completion_args.zsh {
|
||||
clap_complete::Shell::Zsh
|
||||
} else if completion_matches.fish {
|
||||
} else if completion_args.fish {
|
||||
clap_complete::Shell::Fish
|
||||
} else {
|
||||
clap_complete::Shell::Bash
|
||||
|
@ -84,13 +84,13 @@ pub(crate) fn cmd_util(
|
|||
clap_complete::generate(shell, &mut app, "jj", &mut buf);
|
||||
ui.stdout_formatter().write_all(&buf)?;
|
||||
}
|
||||
UtilCommands::Mangen(_mangen_matches) => {
|
||||
UtilCommands::Mangen(_mangen_args) => {
|
||||
let mut buf = vec![];
|
||||
let man = clap_mangen::Man::new(command.app().clone());
|
||||
man.render(&mut buf)?;
|
||||
ui.stdout_formatter().write_all(&buf)?;
|
||||
}
|
||||
UtilCommands::ConfigSchema(_config_schema_matches) => {
|
||||
UtilCommands::ConfigSchema(_config_schema_args) => {
|
||||
// TODO(#879): Consider generating entire schema dynamically vs. static file.
|
||||
let buf = include_bytes!("../config-schema.json");
|
||||
ui.stdout_formatter().write_all(buf)?;
|
||||
|
|
|
@ -110,19 +110,11 @@ pub(crate) fn cmd_workspace(
|
|||
subcommand: &WorkspaceCommands,
|
||||
) -> Result<(), CommandError> {
|
||||
match subcommand {
|
||||
WorkspaceCommands::Add(command_matches) => cmd_workspace_add(ui, command, command_matches),
|
||||
WorkspaceCommands::Forget(command_matches) => {
|
||||
cmd_workspace_forget(ui, command, command_matches)
|
||||
}
|
||||
WorkspaceCommands::List(command_matches) => {
|
||||
cmd_workspace_list(ui, command, command_matches)
|
||||
}
|
||||
WorkspaceCommands::Root(command_matches) => {
|
||||
cmd_workspace_root(ui, command, command_matches)
|
||||
}
|
||||
WorkspaceCommands::UpdateStale(command_matches) => {
|
||||
cmd_workspace_update_stale(ui, command, command_matches)
|
||||
}
|
||||
WorkspaceCommands::Add(args) => cmd_workspace_add(ui, command, args),
|
||||
WorkspaceCommands::Forget(args) => cmd_workspace_forget(ui, command, args),
|
||||
WorkspaceCommands::List(args) => cmd_workspace_list(ui, command, args),
|
||||
WorkspaceCommands::Root(args) => cmd_workspace_root(ui, command, args),
|
||||
WorkspaceCommands::UpdateStale(args) => cmd_workspace_update_stale(ui, command, args),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue