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

cli: inline CommandHelper::new()

This constructor has too many arguments enough to introduce a parameter struct,
which would be identical to the CommandHelper type. Let's simply inline it as
there are no external callers.
This commit is contained in:
Yuya Nishihara 2024-03-01 18:25:29 +09:00
parent b926fd844a
commit ee4a06d847

View file

@ -607,39 +607,6 @@ pub struct CommandHelper {
} }
impl CommandHelper { impl CommandHelper {
#[allow(clippy::too_many_arguments)]
pub fn new(
app: Command,
cwd: PathBuf,
string_args: Vec<String>,
matches: ArgMatches,
global_args: GlobalArgs,
settings: UserSettings,
layered_configs: LayeredConfigs,
commit_template_extension: Option<Arc<dyn CommitTemplateLanguageExtension>>,
maybe_workspace_loader: Result<WorkspaceLoader, CommandError>,
store_factories: StoreFactories,
working_copy_factories: HashMap<String, Box<dyn WorkingCopyFactory>>,
) -> Self {
// `cwd` is canonicalized for consistency with `Workspace::workspace_root()` and
// to easily compute relative paths between them.
let cwd = cwd.canonicalize().unwrap_or(cwd);
Self {
app,
cwd,
string_args,
matches,
global_args,
settings,
layered_configs,
commit_template_extension,
maybe_workspace_loader,
store_factories,
working_copy_factories,
}
}
pub fn app(&self) -> &Command { pub fn app(&self) -> &Command {
&self.app &self.app
} }
@ -3043,23 +3010,26 @@ impl CliRunner {
} }
} }
// `cwd` is canonicalized for consistency with `Workspace::workspace_root()` and
// to easily compute relative paths between them.
let cwd = cwd.canonicalize().unwrap_or(cwd);
let settings = UserSettings::from_config(config); let settings = UserSettings::from_config(config);
let working_copy_factories = self let working_copy_factories = self
.working_copy_factories .working_copy_factories
.unwrap_or_else(default_working_copy_factories); .unwrap_or_else(default_working_copy_factories);
let command_helper = CommandHelper::new( let command_helper = CommandHelper {
self.app, app: self.app,
cwd, cwd,
string_args, string_args,
matches, matches,
args.global_args, global_args: args.global_args,
settings, settings,
layered_configs, layered_configs,
self.commit_template_extension, commit_template_extension: self.commit_template_extension,
maybe_workspace_loader, maybe_workspace_loader,
self.store_factories.unwrap_or_default(), store_factories: self.store_factories.unwrap_or_default(),
working_copy_factories, working_copy_factories,
); };
for start_hook_fn in self.start_hook_fns { for start_hook_fn in self.start_hook_fns {
start_hook_fn(ui, &command_helper)?; start_hook_fn(ui, &command_helper)?;
} }