pub fn from_options(
        opts: &CliArgs,
    ) -> Result<(Config, Option<LayoutFromYaml>, Options), ConfigError> {
        let clean = match &opts.command {
            Some(Command::Setup(ref setup)) => setup.clean,
            _ => 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,
                Err(e) => {
                    return Err(e);
                }
            }
        } else {
            Config::default()
        };

        let config_options = Options::from_cli(&config.options, opts.command.clone());

        let layout_dir = config_options
            .layout_dir
            .clone()
            .or_else(|| get_layout_dir(opts.config_dir.clone().or_else(find_default_config_dir)));
        let layout_result = LayoutFromYaml::from_path_or_default(
            opts.layout.as_ref(),
            opts.layout_path.as_ref(),
            layout_dir,
        );
        let layout = match layout_result {
            None => None,
            Some(Ok(layout)) => Some(layout),
            Some(Err(e)) => {
                return Err(e);
            }
        };

        if let Some(Command::Setup(ref setup)) = &opts.command {
            setup
                .from_cli_with_options(opts, &config_options)
                .map_or_else(
                    |e| {
                        eprintln!("{:?}", e);
                        process::exit(1);
                    },
                    |_| {},
                );
        };

        Ok((config, layout, config_options))
    }
/// Entrypoint from main
/// Merges options from the config file and the command line options
/// into `[Options]`, the command line options superceding the config
/// file options:
/// 1. command line options (`zellij options`)
/// 2. config options (`config.yaml`)
Entrypoint from main
Merges options from the config file and the command line options
into `[Options]`, the command line options superceding the config
file options:
1. command line options (`zellij options`)
2.
Entrypoint from main Merges options from the config file and the command line options into ` [ Options ] ` the command line options superceding the config file options : 1 . command line options ( ` zellij options ` ) 2 .
pub fn from_options(
        opts: &CliArgs,
    ) -> Result<(Config, Option<LayoutFromYaml>, Options), ConfigError> {
        let clean = match &opts.command {
            Some(Command::Setup(ref setup)) => setup.clean,
            _ => 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,
                Err(e) => {
                    return Err(e);
                }
            }
        } else {
            Config::default()
        };
        let config_options = Options::from_cli(&config.options, opts.command.clone());
        let layout_dir = config_options
            .layout_dir
            .clone()
            .or_else(|| get_layout_dir(opts.config_dir.clone().or_else(find_default_config_dir)));
        let layout_result = LayoutFromYaml::from_path_or_default(
            opts.layout.as_ref(),
            opts.layout_path.as_ref(),
            layout_dir,
        );
        let layout = match layout_result {
            None => None,
            Some(Ok(layout)) => Some(layout),
            Some(Err(e)) => {
                return Err(e);
            }
        };
        if let Some(Command::Setup(ref setup)) = &opts.command {
            setup
                .from_cli_with_options(opts, &config_options)
                .map_or_else(
                    |e| {
                        eprintln!("{:?}", e);
                        process::exit(1);
                    },
                    |_| {},
                );
        };
        Ok((config, layout, config_options))
    }
pub fn from_options ( opts : & CliArgs , ) -> Result < ( Config , Option < LayoutFromYaml > , Options ) , ConfigError > { let clean = match & opts . command { Some ( Command :: Setup ( ref setup ) ) => setup . clean , _ => 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 , Err ( e ) => { return Err ( e ) ; } } } else { Config :: default ( ) } ; let config_options = Options :: from_cli ( & config . options , opts . command . clone ( ) ) ; let layout_dir = config_options . layout_dir . clone ( ) . or_else ( | | get_layout_dir ( opts . config_dir . clone ( ) . or_else ( find_default_config_dir ) ) ) ; let layout_result = LayoutFromYaml :: from_path_or_default ( opts . layout . as_ref ( ) , opts . layout_path . as_ref ( ) , layout_dir , ) ; let layout = match layout_result { None => None , Some ( Ok ( layout ) ) => Some ( layout ) , Some ( Err ( e ) ) => { return Err ( e ) ; } } ; if let Some ( Command :: Setup ( ref setup ) ) = & opts . command { setup . from_cli_with_options ( opts , & config_options ) . map_or_else ( | e | { eprintln ! ( " " e ) ; process :: exit ( 1 ) ; } , | _ | { } , ) ; } ; Ok ( ( config , layout , config_options ) ) }
Entrypoint from main
Merges options from the config file and the command line options
into `[Options]`, the command line options superceding the config
file options:
1. command line options (`zellij options`)
2. config options (`config.yaml`)
Entrypoint from main Merges options from the config file and the command line options into ` [ Options ] ` the command line options superceding the config file options : 1 . command line options ( ` zellij options ` ) 2 . config options ( ` config . yaml ` )
opts
&CliArgs