pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let exit_code = context
        .properties
        .get("status_code")
        .map_or("0", String::as_str);

    if exit_code == "0" {
        None
    } else {
        let mut module = context.new_module("status");
        let config = StatusConfig::try_load(module.config);

        // As we default to disabled=true, we have to check here after loading our config module,
        // before it was only checking against whatever is in the config starship.toml
        if config.disabled {
            return None;
        };

        let parsed = StringFormatter::new(config.format).and_then(|formatter| {
            formatter
                .map_meta(|var, _| match var {
                    "symbol" => Some(config.symbol),
                    _ => None,
                })
                .map_style(|variable| match variable {
                    "style" => Some(Ok(config.style)),
                    _ => None,
                })
                .map(|variable| match variable {
                    "status" => Some(Ok(exit_code)),
                    _ => None,
                })
                .parse(None)
        });

        module.set_segments(match parsed {
            Ok(segments) => segments,
            Err(_error) => {
                log::warn!("Error parsing format string in `status.format`");
                return None;
            }
        });
        Some(module)
    }
}
/// Creates a module with the status of the last command
///
/// Will display the status only if it is not 0
Creates a module with the status of the last command
Will display the status only if it is not 0
Creates a module with the status of the last command Will display the status only if it is not 0
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let exit_code = context
        .properties
        .get("status_code")
        .map_or("0", String::as_str);
    if exit_code == "0" {
        None
    } else {
        let mut module = context.new_module("status");
        let config = StatusConfig::try_load(module.config);
        // As we default to disabled=true, we have to check here after loading our config module,
        // before it was only checking against whatever is in the config starship.toml
        if config.disabled {
            return None;
        };
        let parsed = StringFormatter::new(config.format).and_then(|formatter| {
            formatter
                .map_meta(|var, _| match var {
                    "symbol" => Some(config.symbol),
                    _ => None,
                })
                .map_style(|variable| match variable {
                    "style" => Some(Ok(config.style)),
                    _ => None,
                })
                .map(|variable| match variable {
                    "status" => Some(Ok(exit_code)),
                    _ => None,
                })
                .parse(None)
        });
        module.set_segments(match parsed {
            Ok(segments) => segments,
            Err(_error) => {
                log::warn!("Error parsing format string in `status.format`");
                return None;
            }
        });
        Some(module)
    }
}
pub fn module < ' a > ( context : & ' a Context ) -> Option < Module < ' a > > { let exit_code = context . properties . get ( " " ) . map_or ( " " , String :: as_str ) ; if exit_code == " " { None } else { let mut module = context . new_module ( " " ) ; let config = StatusConfig :: try_load ( module . config ) ; // As we default to disabled=true, we have to check here after loading our config module, // before it was only checking against whatever is in the config starship.toml if config . disabled { return None ; } ; let parsed = StringFormatter :: new ( config . format ) . and_then ( | formatter | { formatter . map_meta ( | var , _ | match var { " " => Some ( config . symbol ) , _ => None , } ) . map_style ( | variable | match variable { " " => Some ( Ok ( config . style ) ) , _ => None , } ) . map ( | variable | match variable { " " => Some ( Ok ( exit_code ) ) , _ => None , } ) . parse ( None ) } ) ; module . set_segments ( match parsed { Ok ( segments ) => segments , Err ( _error ) => { log :: warn ! ( " " ) ; return None ; } } ) ; Some ( module ) } }
Creates a module with the status of the last command
Will display the status only if it is not 0
Creates a module with the status of the last command Will display the status only if it is not 0
context
&'a Context