mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 15:26:25 +00:00
cli: set StoreFactories directly by CommandHelper::new()
This commit is contained in:
parent
f89f91a18b
commit
d99c299ee0
1 changed files with 13 additions and 10 deletions
|
@ -266,12 +266,17 @@ pub struct CommandHelper {
|
|||
}
|
||||
|
||||
impl CommandHelper {
|
||||
pub fn new(app: clap::Command, string_args: Vec<String>, global_args: GlobalArgs) -> Self {
|
||||
pub fn new(
|
||||
app: clap::Command,
|
||||
string_args: Vec<String>,
|
||||
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<WorkspaceCommandHelper, CommandError> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue