fn config_from_file() -> Option<Table> {
        let file_path = if let Ok(path) = env::var("STARSHIP_CONFIG") {
            // Use $STARSHIP_CONFIG as the config path if available
            log::debug!("STARSHIP_CONFIG is set: \n{}", &path);
            path
        } else {
            // Default to using ~/.config/starship.toml
            log::debug!("STARSHIP_CONFIG is not set");
            let config_path = home_dir()?.join(".config/starship.toml");
            let config_path_str = config_path.to_str()?.to_owned();

            log::debug!("Using default config path: {}", config_path_str);
            config_path_str
        };

        let toml_content = match utils::read_file(&file_path) {
            Ok(content) => {
                log::trace!("Config file content: \n{}", &content);
                Some(content)
            }
            Err(e) => {
                log::debug!("Unable to read config file content: \n{}", &e);
                None
            }
        }?;

        let config = toml::from_str(&toml_content).ok()?;
        log::debug!("Config parsed: \n{:?}", &config);
        Some(config)
    }
/// Create a config from a starship configuration file
Create a config from a starship configuration file
Create a config from a starship configuration file
fn config_from_file() -> Option<Table> {
        let file_path = if let Ok(path) = env::var("STARSHIP_CONFIG") {
            // Use $STARSHIP_CONFIG as the config path if available
            log::debug!("STARSHIP_CONFIG is set: \n{}", &path);
            path
        } else {
            // Default to using ~/.config/starship.toml
            log::debug!("STARSHIP_CONFIG is not set");
            let config_path = home_dir()?.join(".config/starship.toml");
            let config_path_str = config_path.to_str()?.to_owned();
            log::debug!("Using default config path: {}", config_path_str);
            config_path_str
        };
        let toml_content = match utils::read_file(&file_path) {
            Ok(content) => {
                log::trace!("Config file content: \n{}", &content);
                Some(content)
            }
            Err(e) => {
                log::debug!("Unable to read config file content: \n{}", &e);
                None
            }
        }?;
        let config = toml::from_str(&toml_content).ok()?;
        log::debug!("Config parsed: \n{:?}", &config);
        Some(config)
    }
fn config_from_file ( ) -> Option < Table > { let file_path = if let Ok ( path ) = env :: var ( " " ) { // Use $STARSHIP_CONFIG as the config path if available log :: debug ! ( " \n " path ) ; path } else { // Default to using ~/.config/starship.toml log :: debug ! ( " " ) ; let config_path = home_dir ( ) ? . join ( " " ) ; let config_path_str = config_path . to_str ( ) ? . to_owned ( ) ; log :: debug ! ( " " config_path_str ) ; config_path_str } ; let toml_content = match utils :: read_file ( & file_path ) { Ok ( content ) => { log :: trace ! ( " \n " content ) ; Some ( content ) } Err ( e ) => { log :: debug ! ( " \n " e ) ; None } } ? ; let config = toml :: from_str ( & toml_content ) . ok ( ) ? ; log :: debug ! ( " \n " config ) ; Some ( config ) }
Create a config from a starship configuration file
Create a config from a starship configuration file