aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-05-12 22:37:17 +0200
committera-kenji <aks.kenji@protonmail.com>2021-05-14 11:45:19 +0200
commitd667e5ed81fbaef003fe9f01a4bcdbffe5dd0928 (patch)
treea7389c2f167a743ef568db6cae4139ebf5b02e38 /src/main.rs
parentMerge pull request #465 from a-kenji/set-data-dir (diff)
downloadsl0ppij-d667e5ed81fbaef003fe9f01a4bcdbffe5dd0928.tar.gz
sl0ppij-d667e5ed81fbaef003fe9f01a4bcdbffe5dd0928.tar.xz
sl0ppij-d667e5ed81fbaef003fe9f01a4bcdbffe5dd0928.zip
Add `check` flag to the setup subcommand
* The check option communicates default and config options to the user as well as optional compile time features * Move generate-completion from a subcommand to a flag in the setup subcommand
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/main.rs b/src/main.rs
index cb016067..c1f0f387 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,9 @@ mod server;
mod tests;
use client::{boundaries, layout, panes, start_client, tab};
-use common::{command_is_executing, errors, os_input_output, pty, screen, setup, utils, wasm_vm};
+use common::{
+ command_is_executing, errors, os_input_output, pty, screen, setup::Setup, utils, wasm_vm,
+};
use server::start_server;
use structopt::StructOpt;
@@ -22,33 +24,19 @@ use std::convert::TryFrom;
pub fn main() {
let opts = CliArgs::from_args();
- 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);
- }
- };
- let config_options = Options::from_cli(&config.options, opts.option.clone());
- if let Some(crate::cli::ConfigCli::GenerateCompletion { shell }) = opts.option {
- let shell = match shell.as_ref() {
- "bash" => structopt::clap::Shell::Bash,
- "fish" => structopt::clap::Shell::Fish,
- "zsh" => structopt::clap::Shell::Zsh,
- "powerShell" => structopt::clap::Shell::PowerShell,
- "elvish" => structopt::clap::Shell::Elvish,
- other => {
- eprintln!("Unsupported shell: {}", other);
+ if let Some(crate::cli::ConfigCli::Setup(setup)) = opts.option.clone() {
+ Setup::from_cli(&setup, opts).expect("Failed to print to stdout");
+ std::process::exit(0);
+ } else {
+ 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);
}
};
- let mut out = std::io::stdout();
- CliArgs::clap().gen_completions_to("zellij", shell, &mut out);
- } else if let Some(crate::cli::ConfigCli::Setup { .. }) = opts.option {
- setup::dump_default_config().expect("Failed to print to stdout");
- std::process::exit(0);
- } else {
+ let config_options = Options::from_cli(&config.options, opts.option.clone());
atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap();
atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap();
let server_os_input = get_server_os_input();