From ee4a06d847932c7da43ec8a23d901a414d8c7fd2 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 1 Mar 2024 18:25:29 +0900 Subject: [PATCH] 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. --- cli/src/cli_util.rs | 48 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 13166011f0..f182384e08 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -607,39 +607,6 @@ pub struct CommandHelper { } impl CommandHelper { - #[allow(clippy::too_many_arguments)] - pub fn new( - app: Command, - cwd: PathBuf, - string_args: Vec, - matches: ArgMatches, - global_args: GlobalArgs, - settings: UserSettings, - layered_configs: LayeredConfigs, - commit_template_extension: Option>, - maybe_workspace_loader: Result, - store_factories: StoreFactories, - working_copy_factories: HashMap>, - ) -> 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 { &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 working_copy_factories = self .working_copy_factories .unwrap_or_else(default_working_copy_factories); - let command_helper = CommandHelper::new( - self.app, + let command_helper = CommandHelper { + app: self.app, cwd, string_args, matches, - args.global_args, + global_args: args.global_args, settings, layered_configs, - self.commit_template_extension, + commit_template_extension: self.commit_template_extension, maybe_workspace_loader, - self.store_factories.unwrap_or_default(), + store_factories: self.store_factories.unwrap_or_default(), working_copy_factories, - ); + }; for start_hook_fn in self.start_hook_fns { start_hook_fn(ui, &command_helper)?; }