diff --git a/src/cli_util.rs b/src/cli_util.rs index 53149b123..542354ddc 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -266,12 +266,17 @@ pub struct CommandHelper { } impl CommandHelper { - pub fn new(app: clap::Command, string_args: Vec, global_args: GlobalArgs) -> Self { + pub fn new( + app: clap::Command, + string_args: Vec, + global_args: GlobalArgs, + store_factories: StoreFactories, + ) -> Self { Self { app, string_args, global_args, - store_factories: StoreFactories::default(), + store_factories, } } @@ -287,10 +292,6 @@ impl CommandHelper { &self.global_args } - pub fn set_store_factories(&mut self, store_factories: StoreFactories) { - self.store_factories = store_factories; - } - pub fn workspace_helper(&self, ui: &mut Ui) -> Result { let workspace = self.load_workspace(ui)?; let mut workspace_command = self.resolve_operation(ui, workspace)?; @@ -1752,10 +1753,12 @@ impl CliRunner { ui.reset(crate::config::read_config()?); let string_args = expand_args(ui, &self.app, std::env::args_os())?; let (matches, args) = parse_args(ui, &self.app, &self.tracing_subscription, &string_args)?; - let mut command_helper = CommandHelper::new(self.app, string_args, args.global_args); - if let Some(store_factories) = self.store_factories { - command_helper.set_store_factories(store_factories); - } + let command_helper = CommandHelper::new( + self.app, + string_args, + args.global_args, + self.store_factories.unwrap_or_default(), + ); (self.dispatch_fn)(ui, &command_helper, &matches) }