2019-08-20 04:42:25 +00:00
|
|
|
// While adding out new module add out module to src/module.rs ALL_MODULES const array also.
|
2019-09-26 02:55:47 +00:00
|
|
|
mod aws;
|
2019-04-05 01:35:24 +00:00
|
|
|
mod character;
|
2019-08-08 17:25:30 +00:00
|
|
|
mod cmd_duration;
|
2019-10-05 18:25:25 +00:00
|
|
|
mod conda;
|
2020-02-04 23:27:06 +00:00
|
|
|
mod crystal;
|
2019-04-05 00:35:35 +00:00
|
|
|
mod directory;
|
2019-10-02 06:56:49 +00:00
|
|
|
mod dotnet;
|
2020-02-06 03:57:04 +00:00
|
|
|
mod elm;
|
2019-09-26 08:30:58 +00:00
|
|
|
mod env_var;
|
2019-04-27 02:07:07 +00:00
|
|
|
mod git_branch;
|
2019-12-06 16:57:42 +00:00
|
|
|
mod git_commit;
|
2019-09-05 16:45:04 +00:00
|
|
|
mod git_state;
|
2019-05-14 04:43:11 +00:00
|
|
|
mod git_status;
|
2019-07-19 20:18:52 +00:00
|
|
|
mod golang;
|
2020-01-25 06:48:39 +00:00
|
|
|
mod haskell;
|
2019-12-02 22:37:18 +00:00
|
|
|
mod hg_branch;
|
2019-09-04 17:03:31 +00:00
|
|
|
mod hostname;
|
2019-09-19 23:02:53 +00:00
|
|
|
mod java;
|
2019-08-12 17:42:33 +00:00
|
|
|
mod jobs;
|
2019-10-01 18:58:24 +00:00
|
|
|
mod kubernetes;
|
2019-04-05 00:35:35 +00:00
|
|
|
mod line_break;
|
2019-09-29 05:55:49 +00:00
|
|
|
mod memory_usage;
|
2019-08-25 15:41:20 +00:00
|
|
|
mod nix_shell;
|
2019-04-10 13:22:11 +00:00
|
|
|
mod nodejs;
|
2019-05-01 14:45:56 +00:00
|
|
|
mod package;
|
2019-12-05 18:04:27 +00:00
|
|
|
mod php;
|
2019-04-25 15:06:18 +00:00
|
|
|
mod python;
|
2019-08-13 22:43:29 +00:00
|
|
|
mod ruby;
|
2019-04-21 23:37:34 +00:00
|
|
|
mod rust;
|
2019-12-09 01:42:51 +00:00
|
|
|
mod terraform;
|
2019-09-10 17:54:40 +00:00
|
|
|
mod time;
|
2019-05-20 02:26:12 +00:00
|
|
|
mod username;
|
2019-10-25 01:00:05 +00:00
|
|
|
mod utils;
|
2019-04-04 00:14:26 +00:00
|
|
|
|
2019-08-26 18:09:39 +00:00
|
|
|
#[cfg(feature = "battery")]
|
|
|
|
mod battery;
|
|
|
|
|
2019-10-19 01:51:38 +00:00
|
|
|
use crate::config::{RootModuleConfig, SegmentConfig};
|
2020-01-26 22:37:18 +00:00
|
|
|
use crate::context::{Context, Shell};
|
2019-05-01 20:34:24 +00:00
|
|
|
use crate::module::Module;
|
2019-04-04 16:18:02 +00:00
|
|
|
|
2019-06-10 14:56:17 +00:00
|
|
|
pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
|
2019-04-04 00:14:26 +00:00
|
|
|
match module {
|
2019-10-02 06:56:49 +00:00
|
|
|
// Keep these ordered alphabetically.
|
|
|
|
// Default ordering is handled in configs/mod.rs
|
2019-09-26 02:55:47 +00:00
|
|
|
"aws" => aws::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
#[cfg(feature = "battery")]
|
|
|
|
"battery" => battery::module(context),
|
2019-08-13 16:30:59 +00:00
|
|
|
"character" => character::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"cmd_duration" => cmd_duration::module(context),
|
2019-10-05 18:25:25 +00:00
|
|
|
"conda" => conda::module(context),
|
|
|
|
"directory" => directory::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"dotnet" => dotnet::module(context),
|
2020-02-06 03:57:04 +00:00
|
|
|
"elm" => elm::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"env_var" => env_var::module(context),
|
2019-07-02 20:12:53 +00:00
|
|
|
"git_branch" => git_branch::module(context),
|
2019-12-06 16:57:42 +00:00
|
|
|
"git_commit" => git_commit::module(context),
|
2019-09-05 16:45:04 +00:00
|
|
|
"git_state" => git_state::module(context),
|
2019-07-02 20:12:53 +00:00
|
|
|
"git_status" => git_status::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"golang" => golang::module(context),
|
2020-01-25 06:48:39 +00:00
|
|
|
"haskell" => haskell::module(context),
|
2019-12-02 22:37:18 +00:00
|
|
|
"hg_branch" => hg_branch::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"hostname" => hostname::module(context),
|
2019-09-19 23:02:53 +00:00
|
|
|
"java" => java::module(context),
|
2019-08-12 17:42:33 +00:00
|
|
|
"jobs" => jobs::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"kubernetes" => kubernetes::module(context),
|
|
|
|
"line_break" => line_break::module(context),
|
|
|
|
"memory_usage" => memory_usage::module(context),
|
2019-08-25 15:41:20 +00:00
|
|
|
"nix_shell" => nix_shell::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"nodejs" => nodejs::module(context),
|
|
|
|
"package" => package::module(context),
|
2019-12-05 18:04:27 +00:00
|
|
|
"php" => php::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"python" => python::module(context),
|
|
|
|
"ruby" => ruby::module(context),
|
|
|
|
"rust" => rust::module(context),
|
2019-12-09 01:42:51 +00:00
|
|
|
"terraform" => terraform::module(context),
|
2019-09-10 17:54:40 +00:00
|
|
|
"time" => time::module(context),
|
2020-02-04 23:27:06 +00:00
|
|
|
"crystal" => crystal::module(context),
|
2019-10-02 06:56:49 +00:00
|
|
|
"username" => username::module(context),
|
2019-08-20 04:42:25 +00:00
|
|
|
_ => {
|
|
|
|
eprintln!("Error: Unknown module {}. Use starship module --list to list out all supported modules.", module);
|
|
|
|
None
|
|
|
|
}
|
2019-04-04 00:14:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-02 04:19:08 +00:00
|
|
|
|
|
|
|
pub fn description(module: &str) -> &'static str {
|
|
|
|
match module {
|
|
|
|
"aws" => "The current AWS region and profile",
|
|
|
|
"battery" => "The current charge of the device's battery and its current charging status",
|
|
|
|
"character" => {
|
|
|
|
"A character (usually an arrow) beside where the text is entered in your terminal"
|
|
|
|
}
|
|
|
|
"cmd_duration" => "How long the last command took to execute",
|
|
|
|
"conda" => "The current conda environment, if $CONDA_DEFAULT_ENV is set",
|
|
|
|
"directory" => "The current working directory",
|
|
|
|
"dotnet" => "The relevant version of the .NET Core SDK for the current directory",
|
|
|
|
"env_var" => "Displays the current value of a selected environment variable",
|
|
|
|
"git_branch" => "The active branch of the repo in your current directory",
|
2020-01-07 17:12:40 +00:00
|
|
|
"git_commit" => "The active commit of the repo in your current directory",
|
2020-01-02 04:19:08 +00:00
|
|
|
"git_state" => "The current git operation, and it's progress",
|
|
|
|
"git_status" => "Symbol representing the state of the repo",
|
|
|
|
"golang" => "The currently installed version of Golang",
|
|
|
|
"hg_branch" => "The active branch of the repo in your current directory",
|
|
|
|
"hostname" => "The system hostname",
|
|
|
|
"java" => "The currently installed version of Java",
|
|
|
|
"jobs" => "The current number of jobs running",
|
|
|
|
"kubernetes" => "The current Kubernetes context name and, if set, the namespace",
|
|
|
|
"line_break" => "Separates the prompt into two lines",
|
|
|
|
"memory_usage" => "Current system memory and swap usage",
|
|
|
|
"nix_shell" => "The nix-shell environment",
|
|
|
|
"nodejs" => "The currently installed version of NodeJS",
|
|
|
|
"package" => "The package version of the current directory's project",
|
|
|
|
"php" => "The currently installed version of PHP",
|
|
|
|
"python" => "The currently installed version of Python",
|
|
|
|
"ruby" => "The currently installed version of Ruby",
|
|
|
|
"rust" => "The currently installed version of Rust",
|
|
|
|
"terraform" => "The currently selected terraform workspace and version",
|
|
|
|
"time" => "The current local time",
|
|
|
|
"username" => "The active user's username",
|
|
|
|
_ => "<no description>",
|
|
|
|
}
|
|
|
|
}
|