summaryrefslogtreecommitdiffstats
path: root/src/modules/mod.rs
blob: 23d82601f2238a79da52c2e366e8dd42ac56e5bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// While adding out new module add out module to src/module.rs ALL_MODULES const array also.
mod character;
mod cmd_duration;
mod directory;
mod git_branch;
mod git_status;
mod golang;
mod hostname;
mod jobs;
mod line_break;
mod nix_shell;
mod nodejs;
mod package;
mod python;
mod ruby;
mod rust;
mod username;

#[cfg(feature = "battery")]
mod battery;

use crate::context::Context;
use crate::module::Module;

pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
    match module {
        "directory" => directory::module(context),
        "character" => character::module(context),
        "nodejs" => nodejs::module(context),
        "rust" => rust::module(context),
        "python" => python::module(context),
        "ruby" => ruby::module(context),
        "golang" => golang::module(context),
        "line_break" => line_break::module(context),
        "package" => package::module(context),
        "git_branch" => git_branch::module(context),
        "git_status" => git_status::module(context),
        "username" => username::module(context),
        #[cfg(feature = "battery")]
        "battery" => battery::module(context),
        "cmd_duration" => cmd_duration::module(context),
        "jobs" => jobs::module(context),
        "nix_shell" => nix_shell::module(context),
        "hostname" => hostname::module(context),

        _ => {
            eprintln!("Error: Unknown module {}. Use starship module --list to list out all supported modules.", module);
            None
        }
    }
}