pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let mut module = context.new_module("cmd_duration");

    let arguments = &context.arguments;
    let elapsed = arguments
        .value_of("cmd_duration")
        .unwrap_or("invalid_time")
        .parse::<u64>()
        .ok()?;

    let signed_config_min = module.config_value_i64("min_time").unwrap_or(2);

    /* TODO: Once error handling is implemented, warn the user if their config
    min time is nonsensical */
    if signed_config_min < 0 {
        log::debug!(
            "[WARN]: min_time in [cmd_duration] ({}) was less than zero",
            signed_config_min
        );
        return None;
    }

    let config_min = signed_config_min as u64;

    let module_color = match elapsed {
        time if time < config_min => return None,
        _ => module
            .config_value_style("style")
            .unwrap_or_else(|| Color::Yellow.bold()),
    };

    module.set_style(module_color);
    module.new_segment("cmd_duration", &format!("took {}", render_time(elapsed)));
    module.get_prefix().set_value("");

    Some(module)
}
/// Outputs the time it took the last command to execute
///
/// Will only print if last command took more than a certain amount of time to
/// execute. Default is two seconds, but can be set by config option `min_time`.
Outputs the time it took the last command to execute
Will only print if last command took more than a certain amount of time to
execute. Default is two seconds, but can be set by config option `min_time`.
Outputs the time it took the last command to execute Will only print if last command took more than a certain amount of time to execute . Default is two seconds but can be set by config option ` min_time ` .
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let mut module = context.new_module("cmd_duration");
    let arguments = &context.arguments;
    let elapsed = arguments
        .value_of("cmd_duration")
        .unwrap_or("invalid_time")
        .parse::<u64>()
        .ok()?;
    let signed_config_min = module.config_value_i64("min_time").unwrap_or(2);
    /* TODO: Once error handling is implemented, warn the user if their config
    min time is nonsensical */
    if signed_config_min < 0 {
        log::debug!(
            "[WARN]: min_time in [cmd_duration] ({}) was less than zero",
            signed_config_min
        );
        return None;
    }
    let config_min = signed_config_min as u64;
    let module_color = match elapsed {
        time if time < config_min => return None,
        _ => module
            .config_value_style("style")
            .unwrap_or_else(|| Color::Yellow.bold()),
    };
    module.set_style(module_color);
    module.new_segment("cmd_duration", &format!("took {}", render_time(elapsed)));
    module.get_prefix().set_value("");
    Some(module)
}
pub fn module < ' a > ( context : & ' a Context ) -> Option < Module < ' a > > { let mut module = context . new_module ( " " ) ; let arguments = & context . arguments ; let elapsed = arguments . value_of ( " " ) . unwrap_or ( " " ) . parse :: < u64 > ( ) . ok ( ) ? ; let signed_config_min = module . config_value_i64 ( " " ) . unwrap_or ( 2 ) ; /* TODO: Once error handling is implemented, warn the user if their config
    min time is nonsensical */ if signed_config_min < 0 { log :: debug ! ( " " signed_config_min ) ; return None ; } let config_min = signed_config_min as u64 ; let module_color = match elapsed { time if time < config_min => return None , _ => module . config_value_style ( " " ) . unwrap_or_else ( | | Color :: Yellow . bold ( ) ) , } ; module . set_style ( module_color ) ; module . new_segment ( " " , & format ! ( " " render_time ( elapsed ) ) ) ; module . get_prefix ( ) . set_value ( " " ) ; Some ( module ) }
Outputs the time it took the last command to execute
Will only print if last command took more than a certain amount of time to
execute.
Outputs the time it took the last command to execute Will only print if last command took more than a certain amount of time to execute .
context
&'a Context