diff options
author | a-kenji <aks.kenji@protonmail.com> | 2021-07-27 07:45:08 +0200 |
---|---|---|
committer | a-kenji <aks.kenji@protonmail.com> | 2021-07-28 18:17:49 +0200 |
commit | 331807c16a4ad1cdfc58ffe4a6be1bd445d043d4 (patch) | |
tree | b399a906461fcf158f898f62ebdf22d85baa8c09 /src | |
parent | a62dea4ea32583613912ccc965e2e9bcecc8a821 (diff) |
Simplify deserialization for layouts, config
Simplify deserialzation for layouts, config and config options.
Move the logic responsible to `Setup::from_options()` in order
to be able to parse `main.rs` as well as adding new command easier.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/main.rs b/src/main.rs index 22f373a2c..1a3a16ed6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,16 +5,14 @@ mod tests; use crate::install::populate_data_dir; use sessions::{assert_session, assert_session_ne, get_active_session, list_sessions}; -use std::convert::TryFrom; use std::process; use zellij_client::{os_input_output::get_client_os_input, start_client, ClientInfo}; use zellij_server::{os_input_output::get_server_os_input, start_server}; use zellij_utils::{ cli::{CliArgs, Command, Sessions}, consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR}, - input::{config::Config, layout::Layout, options::Options}, logging::*, - setup::{find_default_config_dir, get_default_data_dir, get_layout_dir, Setup}, + setup::{get_default_data_dir, Setup}, structopt::StructOpt, }; @@ -26,24 +24,13 @@ pub fn main() { list_sessions(); } - let config = match Config::try_from(&opts) { - Ok(config) => config, + let (config, layout, config_options) = match Setup::from_options(&opts) { + Ok(results) => results, Err(e) => { - eprintln!("There was an error in the config file:\n{}", e); + eprintln!("{}", e); process::exit(1); } }; - let config_options = Options::from_cli(&config.options, opts.command.clone()); - - if let Some(Command::Setup(ref setup)) = opts.command { - Setup::from_cli(setup, &opts, &config_options).map_or_else( - |e| { - eprintln!("{:?}", e); - process::exit(1); - }, - |_| {}, - ); - }; atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap(); atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); @@ -94,15 +81,6 @@ pub fn main() { #[cfg(not(disable_automatic_asset_installation))] populate_data_dir(&data_dir); - let layout_dir = config_options.layout_dir.or_else(|| { - get_layout_dir(opts.config_dir.clone().or_else(find_default_config_dir)) - }); - let layout = Layout::from_path_or_default( - opts.layout.as_ref(), - opts.layout_path.as_ref(), - layout_dir, - ); - start_client( Box::new(os_input), opts, |