1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-02 16:40:51 +00:00
starship/src/modules/mod.rs

340 lines
14 KiB
Rust
Raw Normal View History

// While adding out new module add out module to src/module.rs ALL_MODULES const array also.
mod aws;
mod azure;
mod buf;
2022-08-01 10:59:36 +00:00
mod bun;
mod c;
2019-04-05 01:35:24 +00:00
mod character;
mod cmake;
mod cmd_duration;
mod cobol;
2019-10-05 18:25:25 +00:00
mod conda;
mod container;
mod crystal;
pub mod custom;
2022-05-26 14:42:31 +00:00
mod daml;
2020-07-29 15:38:23 +00:00
mod dart;
mod deno;
2019-04-05 00:35:35 +00:00
mod directory;
mod direnv;
mod docker_context;
mod dotnet;
2020-03-02 03:29:27 +00:00
mod elixir;
mod elm;
mod env_var;
mod erlang;
mod fennel;
mod fill;
mod fossil_branch;
mod fossil_metrics;
mod gcloud;
mod git_branch;
2019-12-06 16:57:42 +00:00
mod git_commit;
mod git_metrics;
mod git_state;
2019-05-14 04:43:11 +00:00
mod git_status;
mod gleam;
mod golang;
mod gradle;
mod guix_shell;
mod haskell;
mod haxe;
mod helm;
2019-12-02 22:37:18 +00:00
mod hg_branch;
mod hostname;
mod java;
mod jobs;
mod julia;
mod kotlin;
mod kubernetes;
2019-04-05 00:35:35 +00:00
mod line_break;
mod localip;
mod lua;
mod memory_usage;
mod meson;
mod nim;
2019-08-25 15:41:20 +00:00
mod nix_shell;
2019-04-10 13:22:11 +00:00
mod nodejs;
mod ocaml;
mod opa;
mod openstack;
feat: Add operating system module (#4109) * docs(os): Add os module documentation * docs(os): Add os to Default Prompt Format * chore(os): Update config file schema * feat(os): Add os entries and declarations * feat(os): Add os module and config * fix(os): Obey config.disabled * feat(os): make variables 'Unknown'-aware refactor(os): calculate variables in dedicated functions * test(os): Add os module tests * feat(os): make 'name' variable less 'Unknown'-aware * docs(os): Add Preset configurations docs(os): Use emoji as default * feat(os): Use emoji as default test(os): Use emoji as default * fix(os): Add spaces after emoji symbols * chore(os): Update config schema * feat(os): Remove `bitness` variable docs(os): Remove `bitness` variable test(os): Remove `bitness` test * feat(os): Add Cargo.toml upgrade caution for os_info * refactor(os): Clarify get_symbol function * docs(os): Mention supported operating systems and feature requests * docs(os): Mention os_info inacurracy * test(os): Remove `bitness` leftovers * refactor(os): use nu_ansi_term * refactor(os): add cfg_attr(schemars(deny_unknown_fields)) * chore(os): update config schema * docs(os): expose details block * feat(os): add garuda linux * chore(os): update config schema * feat(os): add case insensitivity * feat(os): add symbols `IndexMap` use `os_info::Type` instead of `String` * test(os): add clippy warn on new os_info::Type case * leave missing case to test github tests * test(os): re-add missing test case * style(os): fix formatting * docs(os): update to match os_info::Type serialization - docs(os): add missing garuda to config - test(os): mention docs updates in warn_on_os_info_update
2022-11-06 21:37:58 +00:00
mod os;
2019-05-01 14:45:56 +00:00
mod package;
mod perl;
2019-12-05 18:04:27 +00:00
mod php;
mod pijul_channel;
2021-10-05 23:27:25 +00:00
mod pulumi;
mod purescript;
2019-04-25 15:06:18 +00:00
mod python;
mod quarto;
mod raku;
mod red;
feat(r-lang): add module for R programming language (#1475) * feat(formatter): Allow scoped variables (#1094) * feat: Allow scoped variables , with the following improvements to the format string parser. - Add documentation to spec - Simplify some syntax in the spec - Rewrite for loop with iterators * Added support for R programming language. * Removed unnecessary debug log used during dev process. * Make the `R` command upper case as the *nix OS executables are case sensitives and the correct command is upper-case. * Changed comments to reflect R features (rather than node.js where code was coming from). * feat(format_string): Allow positional segments (#1138) * feat(format_string): Allow using variables in a style string (#1130) * fix(format_string): Allow multiple variable mappers (#1142) * refactor: Add error handling to variables (#1148) * Squashed commit of changes with meta variables: commit 5beb3bca18f0b0c822b740afb3778ccb1e3a7d19 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Mon Apr 27 09:52:59 2020 +0800 fix: Cache variables in meta variables properly commit 49b9324942dd55350c87107d0e8c7d1592d92e8a Merge: cc575bc 260a1ab Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sun Apr 26 21:34:52 2020 +0800 Merge branch 'feat/format-string' into meta-variables commit cc575bc27cbf87c4197e96d2fa5416d4932e45d7 Merge: 3ed2d32 e0c1901 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sun Apr 26 12:16:12 2020 +0800 Merge branch 'feat/format-string' into meta-variables commit 3ed2d326c9f625930bdd72cea736c1d0eab6d381 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sun Apr 26 11:06:28 2020 +0800 refactor(format_string): Allow returning error in variable mapper commit 766732fe697df947538fe12ca92a8eb8e7bfea3e Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:56:02 2020 +0800 fix: Add test for StyleVariableHolder commit 444334ad206a68132fa6257b83c3992b7b790981 Merge: 479d4a7 9796a66 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:52:27 2020 +0800 Merge branch 'positional-segments' into style-variables commit 9796a66a9679597676e7fd859197fd542e8042dc Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:51:26 2020 +0800 test: Add tests for VariableHolder commit 479d4a72fa58fd8aa777acd8228d4834407a7b6a Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:41:47 2020 +0800 feat: Add trait StyleVariableHolder commit 21d40c6f4e2d12b34fdec4e2e38b6ad0f91217a3 Merge: 3b459f4 e7dd987 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:17:11 2020 +0800 Merge branch 'positional-segments' into style-variables commit e7dd987fd7b01a82c6012ba7055d1dd9b5fd84aa Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 15:10:12 2020 +0800 misc: Minor changes on docs and codes commit 71020b0397a86e850ad5beda926aa9416250025c Author: heyrict <xiezh0831@yahoo.co.jp> Date: Fri Apr 24 20:51:45 2020 +0800 feat(format_string): Add syntax for positional segments commit 3b459f4379b08defce50c57a903502513ad1b2b6 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Wed Apr 22 17:49:15 2020 +0800 fix: Fix clippy commit 2fb052d68cb46680c081f5a0e25e2c3fbdc9e204 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Wed Apr 22 17:02:09 2020 +0800 feat: Add map_style method to feed values in style string * fix: Change error type of StringFormatter::new * fix: Fix rustfmt * tests: Add tests to variable errors * docs: Add documentation * chore: Rename positional to conditional (#1166) * docs: Add docs for format strings (#1083) Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> * refactor(rust): Use format strings (#1063) * Updated to latest string formatter's changes. * feat(format-string): add format string support to battery module (#1158) * update battery module with format string * update battery module docs * update battery module with format string * update battery module docs * fix battery module with new StringFormatter api * fix clippy warnings * Update docs/config/README.md Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> * battery symbols now supports format-string * battery symbols now support format-string remove space between symbol and percentage fix battery config Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> * refactor(golang): Use format strings (#1066) * refactor(golang): Use format strings * docs(golang): Update docs * docs(golang): Update docs * fix: Update to upstream API changes * docs(golang): Update docs Co-authored-by: heyrict <xiezh0831@yahoo.co.jp> * Fixed a few inconsistencies. * Removed string clone in favor of a reference. * Update src/modules/r.rs Reverting the r version string formatting to a more idiomatic way of handling it. Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> * Update src/configs/r.rs Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> * Updated documentation to reflect changes in config. * refactor(java): Added formatter support for Java module. (#1084) * refactor(haskell): Added formatter support for the Haskell module. (#1111) * Added formatter support for the Haskell module. * Updated haskell module with latest formatter code changes. * Changed documentation for latest Haskell string formatter changes. * Fixed a few inconsistencies. * Removed unnecessary variable cloning for using reference instead. * refactor(env_var): Added formatter support for the env_var module (#1180) * refactor(memory_usage): Added formatter support for memory_usage module (#1182) * Migrated the memory usage module to string formatter' support. * Fixed a few inconsistencies. * Removed cloning of variables to instead use references. * refactor(cmd_duration): Use format strings (#1200) * Fixed format issue in code. * Fixed compilation error after adding new 'r' module in root config. * Added .Rproj extension file to be detected with R prog lang. * Aligned R module code with existing ones. * Update src/configs/r.rs Co-authored-by: David Knaack <davidkna@users.noreply.github.com> * fix: Added rconfig to fullconfig and fixed broken api calls * Apply suggestions from code review Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> * Update src/modules/r.rs Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> * Addressed PR comments. Cleaned up code and fixed code errors. * Updated docs for consistency purpose. Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com> * refactor: Renamed the `r` module to `rlang` * test: Provided R fixture and R module renderer test * doc: Updated rlang mod config to reflect latest detection changes * fix: Added missing rlang entry in config/mod * feat: Added version formatted fined grained configuration * Added version_format in R lang documentation. Co-authored-by: David Knaack <davidkna@users.noreply.github.com> * review: Addressed later comments * fix: README was missing a previously present section for Python * Fix: Test was not updated for previous version string upgrade. * fix: Upgraded R version in remaining test. Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> Co-authored-by: John Letey <johnletey@gmail.com> Co-authored-by: Tilmann Meyer <47182955+ATiltedTree@users.noreply.github.com> Co-authored-by: David Knaack <davidkna@users.noreply.github.com> Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2021-05-25 18:13:30 +00:00
mod rlang;
2019-08-13 22:43:29 +00:00
mod ruby;
2019-04-21 23:37:34 +00:00
mod rust;
mod scala;
mod shell;
mod shlvl;
2020-02-26 16:18:19 +00:00
mod singularity;
mod solidity;
mod spack;
mod status;
mod sudo;
2020-07-29 15:36:49 +00:00
mod swift;
mod terraform;
mod time;
mod username;
mod utils;
mod vagrant;
mod vcsh;
mod vlang;
2020-05-21 16:49:49 +00:00
mod zig;
2019-04-04 00:14:26 +00:00
#[cfg(feature = "battery")]
mod battery;
mod typst;
#[cfg(feature = "battery")]
pub use self::battery::{BatteryInfoProvider, BatteryInfoProviderImpl};
use crate::config::ModuleConfig;
use crate::context::{Context, Shell};
2019-05-01 20:34:24 +00:00
use crate::module::Module;
use std::time::Instant;
2019-04-04 16:18:02 +00:00
pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
let start: Instant = Instant::now();
let mut m: Option<Module> = {
match module {
// Keep these ordered alphabetically.
// Default ordering is handled in configs/starship_root.rs
"aws" => aws::module(context),
"azure" => azure::module(context),
#[cfg(feature = "battery")]
"battery" => battery::module(context),
"buf" => buf::module(context),
2022-08-01 10:59:36 +00:00
"bun" => bun::module(context),
"c" => c::module(context),
"character" => character::module(context),
"cmake" => cmake::module(context),
"cmd_duration" => cmd_duration::module(context),
"cobol" => cobol::module(context),
"conda" => conda::module(context),
"container" => container::module(context),
2022-05-26 14:42:31 +00:00
"daml" => daml::module(context),
"dart" => dart::module(context),
"deno" => deno::module(context),
"directory" => directory::module(context),
"direnv" => direnv::module(context),
"docker_context" => docker_context::module(context),
"dotnet" => dotnet::module(context),
"elixir" => elixir::module(context),
"elm" => elm::module(context),
"erlang" => erlang::module(context),
"env_var" => env_var::module(None, context),
"fennel" => fennel::module(context),
"fill" => fill::module(context),
"fossil_branch" => fossil_branch::module(context),
"fossil_metrics" => fossil_metrics::module(context),
"gcloud" => gcloud::module(context),
"git_branch" => git_branch::module(context),
"git_commit" => git_commit::module(context),
"git_metrics" => git_metrics::module(context),
"git_state" => git_state::module(context),
"git_status" => git_status::module(context),
"gleam" => gleam::module(context),
"golang" => golang::module(context),
"gradle" => gradle::module(context),
"guix_shell" => guix_shell::module(context),
"haskell" => haskell::module(context),
"haxe" => haxe::module(context),
"helm" => helm::module(context),
"hg_branch" => hg_branch::module(context),
"hostname" => hostname::module(context),
"java" => java::module(context),
"jobs" => jobs::module(context),
"julia" => julia::module(context),
"kotlin" => kotlin::module(context),
"kubernetes" => kubernetes::module(context),
"line_break" => line_break::module(context),
"localip" => localip::module(context),
"lua" => lua::module(context),
"memory_usage" => memory_usage::module(context),
"meson" => meson::module(context),
"nim" => nim::module(context),
"nix_shell" => nix_shell::module(context),
"nodejs" => nodejs::module(context),
"ocaml" => ocaml::module(context),
"opa" => opa::module(context),
"openstack" => openstack::module(context),
feat: Add operating system module (#4109) * docs(os): Add os module documentation * docs(os): Add os to Default Prompt Format * chore(os): Update config file schema * feat(os): Add os entries and declarations * feat(os): Add os module and config * fix(os): Obey config.disabled * feat(os): make variables 'Unknown'-aware refactor(os): calculate variables in dedicated functions * test(os): Add os module tests * feat(os): make 'name' variable less 'Unknown'-aware * docs(os): Add Preset configurations docs(os): Use emoji as default * feat(os): Use emoji as default test(os): Use emoji as default * fix(os): Add spaces after emoji symbols * chore(os): Update config schema * feat(os): Remove `bitness` variable docs(os): Remove `bitness` variable test(os): Remove `bitness` test * feat(os): Add Cargo.toml upgrade caution for os_info * refactor(os): Clarify get_symbol function * docs(os): Mention supported operating systems and feature requests * docs(os): Mention os_info inacurracy * test(os): Remove `bitness` leftovers * refactor(os): use nu_ansi_term * refactor(os): add cfg_attr(schemars(deny_unknown_fields)) * chore(os): update config schema * docs(os): expose details block * feat(os): add garuda linux * chore(os): update config schema * feat(os): add case insensitivity * feat(os): add symbols `IndexMap` use `os_info::Type` instead of `String` * test(os): add clippy warn on new os_info::Type case * leave missing case to test github tests * test(os): re-add missing test case * style(os): fix formatting * docs(os): update to match os_info::Type serialization - docs(os): add missing garuda to config - test(os): mention docs updates in warn_on_os_info_update
2022-11-06 21:37:58 +00:00
"os" => os::module(context),
"package" => package::module(context),
"perl" => perl::module(context),
"php" => php::module(context),
"pijul_channel" => pijul_channel::module(context),
2021-10-05 23:27:25 +00:00
"pulumi" => pulumi::module(context),
"purescript" => purescript::module(context),
"python" => python::module(context),
"quarto" => quarto::module(context),
"raku" => raku::module(context),
feat(r-lang): add module for R programming language (#1475) * feat(formatter): Allow scoped variables (#1094) * feat: Allow scoped variables , with the following improvements to the format string parser. - Add documentation to spec - Simplify some syntax in the spec - Rewrite for loop with iterators * Added support for R programming language. * Removed unnecessary debug log used during dev process. * Make the `R` command upper case as the *nix OS executables are case sensitives and the correct command is upper-case. * Changed comments to reflect R features (rather than node.js where code was coming from). * feat(format_string): Allow positional segments (#1138) * feat(format_string): Allow using variables in a style string (#1130) * fix(format_string): Allow multiple variable mappers (#1142) * refactor: Add error handling to variables (#1148) * Squashed commit of changes with meta variables: commit 5beb3bca18f0b0c822b740afb3778ccb1e3a7d19 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Mon Apr 27 09:52:59 2020 +0800 fix: Cache variables in meta variables properly commit 49b9324942dd55350c87107d0e8c7d1592d92e8a Merge: cc575bc 260a1ab Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sun Apr 26 21:34:52 2020 +0800 Merge branch 'feat/format-string' into meta-variables commit cc575bc27cbf87c4197e96d2fa5416d4932e45d7 Merge: 3ed2d32 e0c1901 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sun Apr 26 12:16:12 2020 +0800 Merge branch 'feat/format-string' into meta-variables commit 3ed2d326c9f625930bdd72cea736c1d0eab6d381 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sun Apr 26 11:06:28 2020 +0800 refactor(format_string): Allow returning error in variable mapper commit 766732fe697df947538fe12ca92a8eb8e7bfea3e Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:56:02 2020 +0800 fix: Add test for StyleVariableHolder commit 444334ad206a68132fa6257b83c3992b7b790981 Merge: 479d4a7 9796a66 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:52:27 2020 +0800 Merge branch 'positional-segments' into style-variables commit 9796a66a9679597676e7fd859197fd542e8042dc Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:51:26 2020 +0800 test: Add tests for VariableHolder commit 479d4a72fa58fd8aa777acd8228d4834407a7b6a Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:41:47 2020 +0800 feat: Add trait StyleVariableHolder commit 21d40c6f4e2d12b34fdec4e2e38b6ad0f91217a3 Merge: 3b459f4 e7dd987 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 22:17:11 2020 +0800 Merge branch 'positional-segments' into style-variables commit e7dd987fd7b01a82c6012ba7055d1dd9b5fd84aa Author: heyrict <xiezh0831@yahoo.co.jp> Date: Sat Apr 25 15:10:12 2020 +0800 misc: Minor changes on docs and codes commit 71020b0397a86e850ad5beda926aa9416250025c Author: heyrict <xiezh0831@yahoo.co.jp> Date: Fri Apr 24 20:51:45 2020 +0800 feat(format_string): Add syntax for positional segments commit 3b459f4379b08defce50c57a903502513ad1b2b6 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Wed Apr 22 17:49:15 2020 +0800 fix: Fix clippy commit 2fb052d68cb46680c081f5a0e25e2c3fbdc9e204 Author: heyrict <xiezh0831@yahoo.co.jp> Date: Wed Apr 22 17:02:09 2020 +0800 feat: Add map_style method to feed values in style string * fix: Change error type of StringFormatter::new * fix: Fix rustfmt * tests: Add tests to variable errors * docs: Add documentation * chore: Rename positional to conditional (#1166) * docs: Add docs for format strings (#1083) Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> * refactor(rust): Use format strings (#1063) * Updated to latest string formatter's changes. * feat(format-string): add format string support to battery module (#1158) * update battery module with format string * update battery module docs * update battery module with format string * update battery module docs * fix battery module with new StringFormatter api * fix clippy warnings * Update docs/config/README.md Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> * battery symbols now supports format-string * battery symbols now support format-string remove space between symbol and percentage fix battery config Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> * refactor(golang): Use format strings (#1066) * refactor(golang): Use format strings * docs(golang): Update docs * docs(golang): Update docs * fix: Update to upstream API changes * docs(golang): Update docs Co-authored-by: heyrict <xiezh0831@yahoo.co.jp> * Fixed a few inconsistencies. * Removed string clone in favor of a reference. * Update src/modules/r.rs Reverting the r version string formatting to a more idiomatic way of handling it. Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> * Update src/configs/r.rs Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> * Updated documentation to reflect changes in config. * refactor(java): Added formatter support for Java module. (#1084) * refactor(haskell): Added formatter support for the Haskell module. (#1111) * Added formatter support for the Haskell module. * Updated haskell module with latest formatter code changes. * Changed documentation for latest Haskell string formatter changes. * Fixed a few inconsistencies. * Removed unnecessary variable cloning for using reference instead. * refactor(env_var): Added formatter support for the env_var module (#1180) * refactor(memory_usage): Added formatter support for memory_usage module (#1182) * Migrated the memory usage module to string formatter' support. * Fixed a few inconsistencies. * Removed cloning of variables to instead use references. * refactor(cmd_duration): Use format strings (#1200) * Fixed format issue in code. * Fixed compilation error after adding new 'r' module in root config. * Added .Rproj extension file to be detected with R prog lang. * Aligned R module code with existing ones. * Update src/configs/r.rs Co-authored-by: David Knaack <davidkna@users.noreply.github.com> * fix: Added rconfig to fullconfig and fixed broken api calls * Apply suggestions from code review Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> * Update src/modules/r.rs Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> * Addressed PR comments. Cleaned up code and fixed code errors. * Updated docs for consistency purpose. Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com> * refactor: Renamed the `r` module to `rlang` * test: Provided R fixture and R module renderer test * doc: Updated rlang mod config to reflect latest detection changes * fix: Added missing rlang entry in config/mod * feat: Added version formatted fined grained configuration * Added version_format in R lang documentation. Co-authored-by: David Knaack <davidkna@users.noreply.github.com> * review: Addressed later comments * fix: README was missing a previously present section for Python * Fix: Test was not updated for previous version string upgrade. * fix: Upgraded R version in remaining test. Co-authored-by: Zhenhui Xie <xiezh0831@yahoo.co.jp> Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com> Co-authored-by: Luca Rinaldi <lucarin@protonmail.com> Co-authored-by: John Letey <johnletey@gmail.com> Co-authored-by: Tilmann Meyer <47182955+ATiltedTree@users.noreply.github.com> Co-authored-by: David Knaack <davidkna@users.noreply.github.com> Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2021-05-25 18:13:30 +00:00
"rlang" => rlang::module(context),
"red" => red::module(context),
"ruby" => ruby::module(context),
"rust" => rust::module(context),
"scala" => scala::module(context),
"shell" => shell::module(context),
"shlvl" => shlvl::module(context),
"singularity" => singularity::module(context),
"solidity" => solidity::module(context),
"spack" => spack::module(context),
"swift" => swift::module(context),
"status" => status::module(context),
"sudo" => sudo::module(context),
"terraform" => terraform::module(context),
"time" => time::module(context),
"typst" => typst::module(context),
"crystal" => crystal::module(context),
"username" => username::module(context),
"vlang" => vlang::module(context),
"vagrant" => vagrant::module(context),
"vcsh" => vcsh::module(context),
"zig" => zig::module(context),
env if env.starts_with("env_var.") => {
env_var::module(env.strip_prefix("env_var."), context)
}
custom if custom.starts_with("custom.") => {
// SAFETY: We just checked that the module starts with "custom."
custom::module(custom.strip_prefix("custom.").unwrap(), context)
}
_ => {
2022-11-05 11:40:46 +00:00
eprintln!("Error: Unknown module {module}. Use starship module --list to list out all supported modules.");
None
}
}
};
let elapsed = start.elapsed();
log::trace!("Took {:?} to compute module {:?}", elapsed, module);
if elapsed.as_millis() >= 1 {
// If we take less than 1ms to compute a None, then we will not return a module at all
// if we have a module: default duration is 0 so no need to change it
// if we took more than 1ms we want to report that and so--in case we have None currently--
// need to create an empty module just to hold the duration for that case
m.get_or_insert_with(|| context.new_module(module)).duration = elapsed;
2019-04-04 00:14:26 +00:00
}
m
2019-04-04 00:14:26 +00:00
}
pub fn description(module: &str) -> &'static str {
match module {
"aws" => "The current AWS region and profile",
"azure" => "The current Azure subscription",
"battery" => "The current charge of the device's battery and its current charging status",
"buf" => "The currently installed version of the Buf CLI",
2022-08-01 10:59:36 +00:00
"bun" => "The currently installed version of the Bun",
"c" => "Your C compiler type",
"character" => {
"A character (usually an arrow) beside where the text is entered in your terminal"
}
"cmake" => "The currently installed version of CMake",
"cmd_duration" => "How long the last command took to execute",
"cobol" => "The currently installed version of COBOL/GNUCOBOL",
"conda" => "The current conda environment, if $CONDA_DEFAULT_ENV is set",
"container" => "The container indicator, if inside a container.",
"crystal" => "The currently installed version of Crystal",
2022-05-26 14:42:31 +00:00
"daml" => "The Daml SDK version of your project",
2020-07-29 15:38:23 +00:00
"dart" => "The currently installed version of Dart",
"deno" => "The currently installed version of Deno",
"directory" => "The current working directory",
"direnv" => "The currently applied direnv file",
"docker_context" => "The current docker context",
"dotnet" => "The relevant version of the .NET Core SDK for the current directory",
"elixir" => "The currently installed versions of Elixir and OTP",
"elm" => "The currently installed version of Elm",
"erlang" => "Current OTP version",
"fennel" => "The currently installed version of Fennel",
"fill" => "Fills the remaining space on the line with a pad string",
"fossil_branch" => "The active branch of the check-out in your current directory",
"fossil_metrics" => "The currently added/deleted lines in your check-out",
"gcloud" => "The current GCP client configuration",
"git_branch" => "The active branch of the repo in your current directory",
"git_commit" => "The active commit (and tag if any) of the repo in your current directory",
"git_metrics" => "The currently added/deleted lines in your repo",
"git_state" => "The current git operation, and it's progress",
"git_status" => "Symbol representing the state of the repo",
"gleam" => "The currently installed version of Gleam",
"golang" => "The currently installed version of Golang",
"gradle" => "The currently installed version of Gradle",
"guix_shell" => "The guix-shell environment",
"haskell" => "The selected version of the Haskell toolchain",
"haxe" => "The currently installed version of Haxe",
"helm" => "The currently installed version of Helm",
"hg_branch" => "The active branch and topic 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",
"julia" => "The currently installed version of Julia",
"kotlin" => "The currently installed version of Kotlin",
"kubernetes" => "The current Kubernetes context name and, if set, the namespace",
"line_break" => "Separates the prompt into two lines",
"localip" => "The currently assigned ipv4 address",
"lua" => "The currently installed version of Lua",
"memory_usage" => "Current system memory and swap usage",
"meson" => {
"The current Meson environment, if $MESON_DEVENV and $MESON_PROJECT_NAME are set"
}
"nim" => "The currently installed version of Nim",
"nix_shell" => "The nix-shell environment",
"nodejs" => "The currently installed version of NodeJS",
"ocaml" => "The currently installed version of OCaml",
"opa" => "The currently installed version of Open Platform Agent",
"openstack" => "The current OpenStack cloud and project",
feat: Add operating system module (#4109) * docs(os): Add os module documentation * docs(os): Add os to Default Prompt Format * chore(os): Update config file schema * feat(os): Add os entries and declarations * feat(os): Add os module and config * fix(os): Obey config.disabled * feat(os): make variables 'Unknown'-aware refactor(os): calculate variables in dedicated functions * test(os): Add os module tests * feat(os): make 'name' variable less 'Unknown'-aware * docs(os): Add Preset configurations docs(os): Use emoji as default * feat(os): Use emoji as default test(os): Use emoji as default * fix(os): Add spaces after emoji symbols * chore(os): Update config schema * feat(os): Remove `bitness` variable docs(os): Remove `bitness` variable test(os): Remove `bitness` test * feat(os): Add Cargo.toml upgrade caution for os_info * refactor(os): Clarify get_symbol function * docs(os): Mention supported operating systems and feature requests * docs(os): Mention os_info inacurracy * test(os): Remove `bitness` leftovers * refactor(os): use nu_ansi_term * refactor(os): add cfg_attr(schemars(deny_unknown_fields)) * chore(os): update config schema * docs(os): expose details block * feat(os): add garuda linux * chore(os): update config schema * feat(os): add case insensitivity * feat(os): add symbols `IndexMap` use `os_info::Type` instead of `String` * test(os): add clippy warn on new os_info::Type case * leave missing case to test github tests * test(os): re-add missing test case * style(os): fix formatting * docs(os): update to match os_info::Type serialization - docs(os): add missing garuda to config - test(os): mention docs updates in warn_on_os_info_update
2022-11-06 21:37:58 +00:00
"os" => "The current operating system",
"package" => "The package version of the current directory's project",
"perl" => "The currently installed version of Perl",
"php" => "The currently installed version of PHP",
"pijul_channel" => "The current channel of the repo in the current directory",
"pulumi" => "The current username, stack, and installed version of Pulumi",
"purescript" => "The currently installed version of PureScript",
"python" => "The currently installed version of Python",
"quarto" => "The current installed version of quarto",
"raku" => "The currently installed version of Raku",
"red" => "The currently installed version of Red",
"rlang" => "The currently installed version of R",
"ruby" => "The currently installed version of Ruby",
"rust" => "The currently installed version of Rust",
"scala" => "The currently installed version of Scala",
"shell" => "The currently used shell indicator",
"shlvl" => "The current value of SHLVL",
"singularity" => "The currently used Singularity image",
"solidity" => "The current installed version of Solidity",
"spack" => "The current spack environment, if $SPACK_ENV is set",
"status" => "The status of the last command",
"sudo" => "The sudo credentials are currently cached",
"swift" => "The currently installed version of Swift",
"terraform" => "The currently selected terraform workspace and version",
"time" => "The current local time",
"typst" => "The current installed version of typst",
"username" => "The active user's username",
"vagrant" => "The currently installed version of Vagrant",
"vcsh" => "The currently active VCSH repository",
"vlang" => "The currently installed version of V",
2020-05-21 16:49:49 +00:00
"zig" => "The currently installed version of Zig",
_ => "<no description>",
}
}
#[cfg(test)]
mod test {
use super::*;
use crate::module::ALL_MODULES;
#[test]
fn all_modules_have_description() {
for module in ALL_MODULES {
2022-11-05 11:40:46 +00:00
println!("Checking if {module:?} has a description");
assert_ne!(description(module), "<no description>");
}
}
}