mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-26 18:55:26 +03:00
fix(setup): switch setup order (#765)
- commands that don't use the config file now wont throw an error on malformed config files
This commit is contained in:
parent
f616af362c
commit
0ca28486a5
@ -159,6 +159,17 @@ impl Setup {
|
||||
_ => false,
|
||||
};
|
||||
|
||||
// setup functions that don't require deserialisation of the config
|
||||
if let Some(Command::Setup(ref setup)) = &opts.command {
|
||||
setup.from_cli().map_or_else(
|
||||
|e| {
|
||||
eprintln!("{:?}", e);
|
||||
process::exit(1);
|
||||
},
|
||||
|_| {},
|
||||
);
|
||||
};
|
||||
|
||||
let config = if !clean {
|
||||
match Config::try_from(opts) {
|
||||
Ok(config) => config,
|
||||
@ -190,20 +201,22 @@ impl Setup {
|
||||
};
|
||||
|
||||
if let Some(Command::Setup(ref setup)) = &opts.command {
|
||||
setup.from_cli(opts, &config_options).map_or_else(
|
||||
|e| {
|
||||
eprintln!("{:?}", e);
|
||||
process::exit(1);
|
||||
},
|
||||
|_| {},
|
||||
);
|
||||
setup
|
||||
.from_cli_with_options(opts, &config_options)
|
||||
.map_or_else(
|
||||
|e| {
|
||||
eprintln!("{:?}", e);
|
||||
process::exit(1);
|
||||
},
|
||||
|_| {},
|
||||
);
|
||||
};
|
||||
|
||||
Ok((config, layout, config_options))
|
||||
}
|
||||
|
||||
/// General setup helpers
|
||||
pub fn from_cli(&self, opts: &CliArgs, config_options: &Options) -> std::io::Result<()> {
|
||||
pub fn from_cli(&self) -> std::io::Result<()> {
|
||||
if self.clean {
|
||||
return Ok(());
|
||||
}
|
||||
@ -213,11 +226,6 @@ impl Setup {
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
if self.check {
|
||||
Setup::check_defaults_config(opts, config_options)?;
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
if let Some(shell) = &self.generate_completion {
|
||||
Self::generate_completion(shell.into());
|
||||
std::process::exit(0);
|
||||
@ -231,6 +239,19 @@ impl Setup {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Checks the merged configuration
|
||||
pub fn from_cli_with_options(
|
||||
&self,
|
||||
opts: &CliArgs,
|
||||
config_options: &Options,
|
||||
) -> std::io::Result<()> {
|
||||
if self.check {
|
||||
Setup::check_defaults_config(opts, config_options)?;
|
||||
std::process::exit(0);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn check_defaults_config(opts: &CliArgs, config_options: &Options) -> std::io::Result<()> {
|
||||
let data_dir = opts.data_dir.clone().unwrap_or_else(get_default_data_dir);
|
||||
let config_dir = opts.config_dir.clone().or_else(find_default_config_dir);
|
||||
|
Loading…
Reference in New Issue
Block a user