pub fn init_dirs(&mut self, application_type: ApplicationType) -> Result<(), ConfigError> {
        if self.base_path.to_str() == Some("") {
            self.base_path = dir_utils::default_path("", None);
        } else {
            self.base_path = dir_utils::absolute_path(&self.base_path);
        }

        // Create the tari data directory
        dir_utils::create_data_directory(Some(&self.base_path)).map_err(|err| {
            ConfigError::new(
                "We couldn't create a default Tari data directory and have to quit now. This makes us sad :(",
                Some(err.to_string()),
            )
        })?;

        if self.config.to_str() == Some("") {
            self.config = dir_utils::default_path(DEFAULT_CONFIG, Some(&self.base_path));
        }

        if self.log_config.to_str() == Some("") {
            match application_type {
                ApplicationType::BaseNode => {
                    self.log_config = dir_utils::default_path(DEFAULT_LOG_CONFIG, Some(&self.base_path));
                },
                ApplicationType::ConsoleWallet => {
                    self.log_config = dir_utils::default_path(DEFAULT_WALLET_LOG_CONFIG, Some(&self.base_path));
                },
                ApplicationType::MergeMiningProxy => {
                    self.log_config =
                        dir_utils::default_path(DEFAULT_MERGE_MINING_PROXY_LOG_CONFIG, Some(&self.base_path))
                },
            }
        }

        if !self.config.exists() {
            let install = if !self.init {
                prompt("Config file does not exist. We can create a default one for you now, or you can say 'no' here, \
                and generate a customised one at https://config.tari.com.\n\
                Would you like to try the default configuration (Y/n)?")
            } else {
                true
            };

            if install {
                println!(
                    "Installing new config file at {}",
                    self.config.to_str().unwrap_or("[??]")
                );
                install_configuration(&self.config, install_default_config_file);
            }
        }

        if !self.log_config.exists() {
            let install = if !self.init {
                prompt("Logging configuration file does not exist. Would you like to create a new one (Y/n)?")
            } else {
                true
            };
            if install {
                println!(
                    "Installing new logfile configuration at {}",
                    self.log_config.to_str().unwrap_or("[??]")
                );
                match application_type {
                    ApplicationType::BaseNode => {
                        install_configuration(&self.log_config, logging::install_default_logfile_config)
                    },
                    ApplicationType::ConsoleWallet => {
                        install_configuration(&self.log_config, logging::install_default_wallet_logfile_config)
                    },
                    ApplicationType::MergeMiningProxy => install_configuration(
                        &self.log_config,
                        logging::install_default_merge_mining_proxy_logfile_config,
                    ),
                }
            }
        };
        Ok(())
    }
/// Initialize configuration and directories based on ConfigBootstrap options.
///
/// If not present it will create base directory (default ~/.tari/, depending on OS).
/// Log and tari configs will be initialized in the base directory too.
///
/// Without `--init` flag provided configuration and directories will be created only
/// after user's confirmation.
Initialize configuration and directories based on ConfigBootstrap options.
If not present it will create base directory (default ~/.tari/, depending on OS).
Log and tari configs will be initialized in the base directory too.

Without `--init` flag provided configuration and directories will be created only
after user's confirmation.
Initialize configuration and directories based on ConfigBootstrap options . If not present it will create base directory ( default ~ / . tari / depending on OS ) . Log and tari configs will be initialized in the base directory too . Without ` -- init ` flag provided configuration and directories will be created only after user ' s confirmation .
pub fn init_dirs(&mut self, application_type: ApplicationType) -> Result<(), ConfigError> {
        if self.base_path.to_str() == Some("") {
            self.base_path = dir_utils::default_path("", None);
        } else {
            self.base_path = dir_utils::absolute_path(&self.base_path);
        }
        // Create the tari data directory
        dir_utils::create_data_directory(Some(&self.base_path)).map_err(|err| {
            ConfigError::new(
                "We couldn't create a default Tari data directory and have to quit now. This makes us sad :(",
                Some(err.to_string()),
            )
        })?;
        if self.config.to_str() == Some("") {
            self.config = dir_utils::default_path(DEFAULT_CONFIG, Some(&self.base_path));
        }
        if self.log_config.to_str() == Some("") {
            match application_type {
                ApplicationType::BaseNode => {
                    self.log_config = dir_utils::default_path(DEFAULT_LOG_CONFIG, Some(&self.base_path));
                },
                ApplicationType::ConsoleWallet => {
                    self.log_config = dir_utils::default_path(DEFAULT_WALLET_LOG_CONFIG, Some(&self.base_path));
                },
                ApplicationType::MergeMiningProxy => {
                    self.log_config =
                        dir_utils::default_path(DEFAULT_MERGE_MINING_PROXY_LOG_CONFIG, Some(&self.base_path))
                },
            }
        }
        if !self.config.exists() {
            let install = if !self.init {
                prompt("Config file does not exist. We can create a default one for you now, or you can say 'no' here, \
                and generate a customised one at https://config.tari.com.\n\
                Would you like to try the default configuration (Y/n)?")
            } else {
                true
            };
            if install {
                println!(
                    "Installing new config file at {}",
                    self.config.to_str().unwrap_or("[??]")
                );
                install_configuration(&self.config, install_default_config_file);
            }
        }
        if !self.log_config.exists() {
            let install = if !self.init {
                prompt("Logging configuration file does not exist. Would you like to create a new one (Y/n)?")
            } else {
                true
            };
            if install {
                println!(
                    "Installing new logfile configuration at {}",
                    self.log_config.to_str().unwrap_or("[??]")
                );
                match application_type {
                    ApplicationType::BaseNode => {
                        install_configuration(&self.log_config, logging::install_default_logfile_config)
                    },
                    ApplicationType::ConsoleWallet => {
                        install_configuration(&self.log_config, logging::install_default_wallet_logfile_config)
                    },
                    ApplicationType::MergeMiningProxy => install_configuration(
                        &self.log_config,
                        logging::install_default_merge_mining_proxy_logfile_config,
                    ),
                }
            }
        };
        Ok(())
    }
pub fn init_dirs ( & mut self , application_type : ApplicationType ) -> Result < ( ) , ConfigError > { if self . base_path . to_str ( ) == Some ( " " ) { self . base_path = dir_utils :: default_path ( " " , None ) ; } else { self . base_path = dir_utils :: absolute_path ( & self . base_path ) ; } // Create the tari data directory dir_utils :: create_data_directory ( Some ( & self . base_path ) ) . map_err ( | err | { ConfigError :: new ( " " , Some ( err . to_string ( ) ) , ) } ) ? ; if self . config . to_str ( ) == Some ( " " ) { self . config = dir_utils :: default_path ( DEFAULT_CONFIG , Some ( & self . base_path ) ) ; } if self . log_config . to_str ( ) == Some ( " " ) { match application_type { ApplicationType :: BaseNode => { self . log_config = dir_utils :: default_path ( DEFAULT_LOG_CONFIG , Some ( & self . base_path ) ) ; } , ApplicationType :: ConsoleWallet => { self . log_config = dir_utils :: default_path ( DEFAULT_WALLET_LOG_CONFIG , Some ( & self . base_path ) ) ; } , ApplicationType :: MergeMiningProxy => { self . log_config = dir_utils :: default_path ( DEFAULT_MERGE_MINING_PROXY_LOG_CONFIG , Some ( & self . base_path ) ) } , } } if ! self . config . exists ( ) { let install = if ! self . init { prompt ( " \
 \n \
 " ) } else { true } ; if install { println ! ( " " self config to_str ( ) unwrap_or ( " " ) ) ; install_configuration ( & self . config , install_default_config_file ) ; } } if ! self . log_config . exists ( ) { let install = if ! self . init { prompt ( " " ) } else { true } ; if install { println ! ( " " self log_config to_str ( ) unwrap_or ( " " ) ) ; match application_type { ApplicationType :: BaseNode => { install_configuration ( & self . log_config , logging :: install_default_logfile_config ) } , ApplicationType :: ConsoleWallet => { install_configuration ( & self . log_config , logging :: install_default_wallet_logfile_config ) } , ApplicationType :: MergeMiningProxy => install_configuration ( & self . log_config , logging :: install_default_merge_mining_proxy_logfile_config , ) , } } } ; Ok ( ( ) ) }
Initialize configuration and directories based on ConfigBootstrap options.
Initialize configuration and directories based on ConfigBootstrap options .
&mut self
application_type
ApplicationType
&mut self
application_type
ApplicationType