diff options
author | a-kenji <aks.kenji@protonmail.com> | 2021-05-18 11:04:27 +0200 |
---|---|---|
committer | a-kenji <aks.kenji@protonmail.com> | 2021-05-18 11:12:57 +0200 |
commit | 79e7c414b7d9008c526556aad874e9aac1f3289a (patch) | |
tree | 251d16ebb88bf8582b0c54e7697374a609bf044d /src | |
parent | 58a1ff82c1258aacb122f5e16f5d723ef042fb45 (diff) |
Fix `clean` flag
* The setup subcommand was exiting the programm no matter what
even if the `clean` flag was provided.
Now it returns to the
main function on encountering the clean flag.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/main.rs b/src/main.rs index 1e1d4764e..b5dd213f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,36 +17,35 @@ pub fn main() { let opts = CliArgs::from_args(); if let Some(ConfigCli::Setup(setup)) = opts.option.clone() { - Setup::from_cli(&setup, opts).expect("Failed to print to stdout"); - std::process::exit(0); + Setup::from_cli(&setup, &opts).expect("Failed to print to stdout"); + } + + let config = match Config::try_from(&opts) { + Ok(config) => config, + Err(e) => { + eprintln!("There was an error in the config file:\n{}", e); + std::process::exit(1); + } + }; + atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap(); + atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); + if let Some(path) = opts.server { + let os_input = match get_server_os_input() { + Ok(server_os_input) => server_os_input, + Err(e) => { + eprintln!("failed to open terminal:\n{}", e); + std::process::exit(1); + } + }; + start_server(Box::new(os_input), path); } else { - let config = match Config::try_from(&opts) { - Ok(config) => config, + let os_input = match get_client_os_input() { + Ok(os_input) => os_input, Err(e) => { - eprintln!("There was an error in the config file:\n{}", e); + eprintln!("failed to open terminal:\n{}", e); std::process::exit(1); } }; - atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap(); - atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); - if let Some(path) = opts.server { - let os_input = match get_server_os_input() { - Ok(server_os_input) => server_os_input, - Err(e) => { - eprintln!("failed to open terminal:\n{}", e); - std::process::exit(1); - } - }; - start_server(Box::new(os_input), path); - } else { - let os_input = match get_client_os_input() { - Ok(os_input) => os_input, - Err(e) => { - eprintln!("failed to open terminal:\n{}", e); - std::process::exit(1); - } - }; - start_client(Box::new(os_input), opts, config); - } + start_client(Box::new(os_input), opts, config); } } |