1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-10 12:22:21 +00:00
starship/src/configs/mod.rs

300 lines
7.3 KiB
Rust
Raw Normal View History

use indexmap::IndexMap;
use serde::{self, Deserialize, Serialize};
pub mod aws;
pub mod azure;
pub mod battery;
pub mod buf;
2022-08-01 10:59:36 +00:00
pub mod bun;
pub mod c;
pub mod character;
pub mod cmake;
pub mod cmd_duration;
pub mod cobol;
2019-10-05 18:25:25 +00:00
pub mod conda;
pub mod container;
pub mod crystal;
2020-04-11 16:37:24 +00:00
pub mod custom;
2022-05-26 14:42:31 +00:00
pub mod daml;
2020-07-29 15:38:23 +00:00
pub mod dart;
pub mod deno;
pub mod directory;
pub mod docker_context;
pub mod dotnet;
2020-03-02 03:29:27 +00:00
pub mod elixir;
pub mod elm;
pub mod env_var;
pub mod erlang;
pub mod fennel;
pub mod fill;
pub mod fossil_branch;
pub mod fossil_metrics;
pub mod gcloud;
pub mod git_branch;
2019-12-06 16:57:42 +00:00
pub mod git_commit;
pub mod git_metrics;
pub mod git_state;
pub mod git_status;
pub mod go;
pub mod gradle;
pub mod guix_shell;
pub mod haskell;
pub mod haxe;
pub mod helm;
2019-12-02 22:37:18 +00:00
pub mod hg_branch;
pub mod hostname;
pub mod java;
pub mod jobs;
pub mod julia;
pub mod kotlin;
pub mod kubernetes;
pub mod line_break;
pub mod localip;
pub mod lua;
pub mod memory_usage;
pub mod meson;
pub mod nim;
pub mod nix_shell;
pub mod nodejs;
pub mod ocaml;
pub mod opa;
pub 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
pub mod os;
pub mod package;
pub mod perl;
2019-12-05 18:04:27 +00:00
pub mod php;
pub mod pijul_channel;
2021-10-05 23:27:25 +00:00
pub mod pulumi;
pub mod purescript;
pub mod python;
pub mod raku;
pub 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
pub mod rlang;
pub mod ruby;
pub mod rust;
pub mod scala;
pub mod shell;
pub mod shlvl;
2020-02-26 16:18:19 +00:00
pub mod singularity;
pub mod solidity;
pub mod spack;
mod starship_root;
pub mod status;
pub mod sudo;
2020-07-29 15:36:49 +00:00
pub mod swift;
pub mod terraform;
pub mod time;
pub mod username;
pub mod v;
pub mod vagrant;
pub mod vcsh;
2020-05-21 16:49:49 +00:00
pub mod zig;
pub use starship_root::*;
#[derive(Serialize, Deserialize, Clone, Default)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct FullConfig<'a> {
// Meta
#[serde(rename = "$schema")]
schema: String,
// Root config
#[serde(flatten)]
root: StarshipRootConfig,
// modules
#[serde(borrow)]
aws: aws::AwsConfig<'a>,
#[serde(borrow)]
azure: azure::AzureConfig<'a>,
#[serde(borrow)]
battery: battery::BatteryConfig<'a>,
#[serde(borrow)]
buf: buf::BufConfig<'a>,
#[serde(borrow)]
2022-08-01 10:59:36 +00:00
bun: bun::BunConfig<'a>,
#[serde(borrow)]
c: c::CConfig<'a>,
#[serde(borrow)]
character: character::CharacterConfig<'a>,
#[serde(borrow)]
cmake: cmake::CMakeConfig<'a>,
#[serde(borrow)]
cmd_duration: cmd_duration::CmdDurationConfig<'a>,
#[serde(borrow)]
cobol: cobol::CobolConfig<'a>,
#[serde(borrow)]
conda: conda::CondaConfig<'a>,
#[serde(borrow)]
container: container::ContainerConfig<'a>,
#[serde(borrow)]
crystal: crystal::CrystalConfig<'a>,
#[serde(borrow)]
2022-05-26 14:42:31 +00:00
daml: daml::DamlConfig<'a>,
#[serde(borrow)]
dart: dart::DartConfig<'a>,
#[serde(borrow)]
deno: deno::DenoConfig<'a>,
#[serde(borrow)]
directory: directory::DirectoryConfig<'a>,
#[serde(borrow)]
docker_context: docker_context::DockerContextConfig<'a>,
#[serde(borrow)]
dotnet: dotnet::DotnetConfig<'a>,
#[serde(borrow)]
elixir: elixir::ElixirConfig<'a>,
#[serde(borrow)]
elm: elm::ElmConfig<'a>,
#[serde(borrow)]
env_var: IndexMap<String, env_var::EnvVarConfig<'a>>,
#[serde(borrow)]
erlang: erlang::ErlangConfig<'a>,
#[serde(borrow)]
fennel: fennel::FennelConfig<'a>,
#[serde(borrow)]
fill: fill::FillConfig<'a>,
#[serde(borrow)]
fossil_branch: fossil_branch::FossilBranchConfig<'a>,
#[serde(borrow)]
fossil_metrics: fossil_metrics::FossilMetricsConfig<'a>,
#[serde(borrow)]
gcloud: gcloud::GcloudConfig<'a>,
#[serde(borrow)]
git_branch: git_branch::GitBranchConfig<'a>,
#[serde(borrow)]
git_commit: git_commit::GitCommitConfig<'a>,
#[serde(borrow)]
git_metrics: git_metrics::GitMetricsConfig<'a>,
#[serde(borrow)]
git_state: git_state::GitStateConfig<'a>,
#[serde(borrow)]
git_status: git_status::GitStatusConfig<'a>,
#[serde(borrow)]
golang: go::GoConfig<'a>,
#[serde(borrow)]
gradle: gradle::GradleConfig<'a>,
#[serde(borrow)]
guix_shell: guix_shell::GuixShellConfig<'a>,
#[serde(borrow)]
haskell: haskell::HaskellConfig<'a>,
#[serde(borrow)]
haxe: haxe::HaxeConfig<'a>,
#[serde(borrow)]
helm: helm::HelmConfig<'a>,
#[serde(borrow)]
hg_branch: hg_branch::HgBranchConfig<'a>,
#[serde(borrow)]
hostname: hostname::HostnameConfig<'a>,
#[serde(borrow)]
java: java::JavaConfig<'a>,
#[serde(borrow)]
jobs: jobs::JobsConfig<'a>,
#[serde(borrow)]
julia: julia::JuliaConfig<'a>,
#[serde(borrow)]
kotlin: kotlin::KotlinConfig<'a>,
#[serde(borrow)]
kubernetes: kubernetes::KubernetesConfig<'a>,
line_break: line_break::LineBreakConfig,
#[serde(borrow)]
localip: localip::LocalipConfig<'a>,
#[serde(borrow)]
lua: lua::LuaConfig<'a>,
#[serde(borrow)]
memory_usage: memory_usage::MemoryConfig<'a>,
#[serde(borrow)]
meson: meson::MesonConfig<'a>,
#[serde(borrow)]
nim: nim::NimConfig<'a>,
#[serde(borrow)]
nix_shell: nix_shell::NixShellConfig<'a>,
#[serde(borrow)]
nodejs: nodejs::NodejsConfig<'a>,
#[serde(borrow)]
ocaml: ocaml::OCamlConfig<'a>,
#[serde(borrow)]
opa: opa::OpaConfig<'a>,
#[serde(borrow)]
openstack: openstack::OspConfig<'a>,
#[serde(borrow)]
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::OSConfig<'a>,
#[serde(borrow)]
package: package::PackageConfig<'a>,
#[serde(borrow)]
perl: perl::PerlConfig<'a>,
#[serde(borrow)]
php: php::PhpConfig<'a>,
#[serde(borrow)]
pijul_channel: pijul_channel::PijulConfig<'a>,
#[serde(borrow)]
2021-10-05 23:27:25 +00:00
pulumi: pulumi::PulumiConfig<'a>,
#[serde(borrow)]
purescript: purescript::PureScriptConfig<'a>,
#[serde(borrow)]
python: python::PythonConfig<'a>,
#[serde(borrow)]
raku: raku::RakuConfig<'a>,
#[serde(borrow)]
red: red::RedConfig<'a>,
#[serde(borrow)]
rlang: rlang::RLangConfig<'a>,
#[serde(borrow)]
ruby: ruby::RubyConfig<'a>,
#[serde(borrow)]
rust: rust::RustConfig<'a>,
#[serde(borrow)]
scala: scala::ScalaConfig<'a>,
#[serde(borrow)]
shell: shell::ShellConfig<'a>,
#[serde(borrow)]
shlvl: shlvl::ShLvlConfig<'a>,
#[serde(borrow)]
singularity: singularity::SingularityConfig<'a>,
#[serde(borrow)]
solidity: solidity::SolidityConfig<'a>,
#[serde(borrow)]
spack: spack::SpackConfig<'a>,
#[serde(borrow)]
status: status::StatusConfig<'a>,
#[serde(borrow)]
sudo: sudo::SudoConfig<'a>,
#[serde(borrow)]
swift: swift::SwiftConfig<'a>,
#[serde(borrow)]
terraform: terraform::TerraformConfig<'a>,
#[serde(borrow)]
time: time::TimeConfig<'a>,
#[serde(borrow)]
username: username::UsernameConfig<'a>,
#[serde(borrow)]
vagrant: vagrant::VagrantConfig<'a>,
#[serde(borrow)]
vcsh: vcsh::VcshConfig<'a>,
#[serde(borrow)]
vlang: v::VConfig<'a>,
#[serde(borrow)]
zig: zig::ZigConfig<'a>,
#[serde(borrow)]
custom: IndexMap<String, custom::CustomConfig<'a>>,
}
#[cfg(test)]
mod test {
use super::*;
use crate::module::ALL_MODULES;
use toml::value::Value;
#[test]
fn test_all_modules_in_full_config() {
let full_cfg = Value::try_from(FullConfig::default()).unwrap();
let cfg_table = full_cfg.as_table().unwrap();
for module in ALL_MODULES {
assert!(cfg_table.contains_key(*module));
}
}
}