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

    let repo = context.get_repo().ok()?;
    let repo_root = repo.root.as_ref()?;
    let repo_state = repo.state?;
    let state_description = get_state_description(repo_state, repo_root);

    if let StateDescription::Clean = state_description {
        return None;
    }

    let module_style = module
        .config_value_style("style")
        .unwrap_or_else(|| Color::Yellow.bold());
    module.set_style(module_style);
    module.get_prefix().set_value("(");
    module.get_suffix().set_value(") ");

    let label = match state_description {
        StateDescription::Label(label) => label,
        StateDescription::LabelAndProgress(label, _) => label,
        // Should only be possible if you've added a new variant to StateDescription
        _ => panic!("Expected to have a label at this point in the control flow."),
    };

    module.new_segment(label.segment_name, label.message_default);

    if let StateDescription::LabelAndProgress(_, progress) = state_description {
        module.new_segment("progress_current", &format!(" {}", progress.current));
        module.new_segment("progress_divider", "/");
        module.new_segment("progress_total", &format!("{}", progress.total));
    }

    Some(module)
}
/// Creates a module with the state of the git repository at the current directory
///
/// During a git operation it will show: REBASING, BISECTING, MERGING, etc.
/// If the progress information is available (e.g. rebasing 3/10), it will show that too.
Creates a module with the state of the git repository at the current directory
During a git operation it will show: REBASING, BISECTING, MERGING, etc.
If the progress information is available , it will show that too.
Creates a module with the state of the git repository at the current directory During a git operation it will show : REBASING BISECTING MERGING etc . If the progress information is available it will show that too .
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let mut module = context.new_module("git_state");
    let repo = context.get_repo().ok()?;
    let repo_root = repo.root.as_ref()?;
    let repo_state = repo.state?;
    let state_description = get_state_description(repo_state, repo_root);
    if let StateDescription::Clean = state_description {
        return None;
    }
    let module_style = module
        .config_value_style("style")
        .unwrap_or_else(|| Color::Yellow.bold());
    module.set_style(module_style);
    module.get_prefix().set_value("(");
    module.get_suffix().set_value(") ");
    let label = match state_description {
        StateDescription::Label(label) => label,
        StateDescription::LabelAndProgress(label, _) => label,
        // Should only be possible if you've added a new variant to StateDescription
        _ => panic!("Expected to have a label at this point in the control flow."),
    };
    module.new_segment(label.segment_name, label.message_default);
    if let StateDescription::LabelAndProgress(_, progress) = state_description {
        module.new_segment("progress_current", &format!(" {}", progress.current));
        module.new_segment("progress_divider", "/");
        module.new_segment("progress_total", &format!("{}", progress.total));
    }
    Some(module)
}
pub fn module < ' a > ( context : & ' a Context ) -> Option < Module < ' a > > { let mut module = context . new_module ( " " ) ; let repo = context . get_repo ( ) . ok ( ) ? ; let repo_root = repo . root . as_ref ( ) ? ; let repo_state = repo . state ? ; let state_description = get_state_description ( repo_state , repo_root ) ; if let StateDescription :: Clean = state_description { return None ; } let module_style = module . config_value_style ( " " ) . unwrap_or_else ( | | Color :: Yellow . bold ( ) ) ; module . set_style ( module_style ) ; module . get_prefix ( ) . set_value ( " " ) ; module . get_suffix ( ) . set_value ( " " ) ; let label = match state_description { StateDescription :: Label ( label ) => label , StateDescription :: LabelAndProgress ( label , _ ) => label , // Should only be possible if you've added a new variant to StateDescription _ => panic ! ( " " ) , } ; module . new_segment ( label . segment_name , label . message_default ) ; if let StateDescription :: LabelAndProgress ( _ , progress ) = state_description { module . new_segment ( " " , & format ! ( " " progress current ) ) ; module . new_segment ( " " , " " ) ; module . new_segment ( " " , & format ! ( " " progress total ) ) ; } Some ( module ) }
Creates a module with the state of the git repository at the current directory
During a git operation it will show: REBASING, BISECTING, MERGING, etc.
Creates a module with the state of the git repository at the current directory During a git operation it will show : REBASING BISECTING MERGING etc .
context
&'a Context