2021-03-31 15:31:55 +00:00
|
|
|
use crate::config::ModuleConfig;
|
|
|
|
use indexmap::IndexMap;
|
|
|
|
use serde::{self, Serialize};
|
|
|
|
use starship_module_config_derive::ModuleConfig;
|
|
|
|
|
2019-10-04 12:42:33 +00:00
|
|
|
pub mod aws;
|
2019-09-30 12:10:35 +00:00
|
|
|
pub mod battery;
|
2019-10-04 12:42:33 +00:00
|
|
|
pub mod character;
|
2020-07-09 19:40:33 +00:00
|
|
|
pub mod cmake;
|
2019-10-15 11:34:48 +00:00
|
|
|
pub mod cmd_duration;
|
2019-10-05 18:25:25 +00:00
|
|
|
pub mod conda;
|
2020-02-04 23:27:06 +00:00
|
|
|
pub mod crystal;
|
2020-04-11 16:37:24 +00:00
|
|
|
pub mod custom;
|
2020-07-29 15:38:23 +00:00
|
|
|
pub mod dart;
|
2021-04-15 13:22:12 +00:00
|
|
|
pub mod deno;
|
2019-10-15 11:34:48 +00:00
|
|
|
pub mod directory;
|
2020-04-05 19:42:55 +00:00
|
|
|
pub mod docker_context;
|
2019-10-02 06:56:49 +00:00
|
|
|
pub mod dotnet;
|
2020-03-02 03:29:27 +00:00
|
|
|
pub mod elixir;
|
2020-02-06 03:57:04 +00:00
|
|
|
pub mod elm;
|
2019-10-15 11:34:48 +00:00
|
|
|
pub mod env_var;
|
2020-04-27 10:09:42 +00:00
|
|
|
pub mod erlang;
|
2020-08-03 21:30:20 +00:00
|
|
|
pub mod gcloud;
|
2019-10-15 11:48:53 +00:00
|
|
|
pub mod git_branch;
|
2019-12-06 16:57:42 +00:00
|
|
|
pub mod git_commit;
|
2021-07-10 20:54:34 +00:00
|
|
|
pub mod git_metrics;
|
2019-11-06 13:00:31 +00:00
|
|
|
pub mod git_state;
|
2019-10-26 06:20:20 +00:00
|
|
|
pub mod git_status;
|
2019-10-13 04:16:56 +00:00
|
|
|
pub mod go;
|
2020-07-17 07:51:25 +00:00
|
|
|
pub mod helm;
|
2019-12-02 22:37:18 +00:00
|
|
|
pub mod hg_branch;
|
2019-10-10 08:21:52 +00:00
|
|
|
pub mod hostname;
|
2019-11-06 12:59:12 +00:00
|
|
|
pub mod java;
|
2019-10-10 08:21:52 +00:00
|
|
|
pub mod jobs;
|
2020-04-03 18:16:34 +00:00
|
|
|
pub mod julia;
|
2020-12-26 14:26:50 +00:00
|
|
|
pub mod kotlin;
|
2019-10-05 09:31:23 +00:00
|
|
|
pub mod kubernetes;
|
2021-07-30 17:33:59 +00:00
|
|
|
pub mod line_break;
|
2020-10-27 18:05:20 +00:00
|
|
|
pub mod lua;
|
2019-10-20 15:26:04 +00:00
|
|
|
pub mod memory_usage;
|
2020-06-09 17:14:47 +00:00
|
|
|
pub mod nim;
|
2019-11-06 12:59:12 +00:00
|
|
|
pub mod nix_shell;
|
2019-10-19 01:51:38 +00:00
|
|
|
pub mod nodejs;
|
2020-05-21 16:43:13 +00:00
|
|
|
pub mod ocaml;
|
2020-10-24 09:46:43 +00:00
|
|
|
pub mod openstack;
|
2019-10-19 01:51:38 +00:00
|
|
|
pub mod package;
|
2020-08-04 16:22:44 +00:00
|
|
|
pub mod perl;
|
2019-12-05 18:04:27 +00:00
|
|
|
pub mod php;
|
2020-05-22 16:26:58 +00:00
|
|
|
pub mod purescript;
|
2019-10-19 01:51:38 +00:00
|
|
|
pub mod python;
|
2021-04-20 16:31:47 +00:00
|
|
|
pub mod red;
|
2021-05-25 18:13:30 +00:00
|
|
|
pub mod rlang;
|
2019-10-19 01:51:38 +00:00
|
|
|
pub mod ruby;
|
2019-09-30 12:10:35 +00:00
|
|
|
pub mod rust;
|
2021-03-14 19:37:00 +00:00
|
|
|
pub mod scala;
|
2021-02-20 14:40:49 +00:00
|
|
|
pub mod shell;
|
2020-08-05 16:30:01 +00:00
|
|
|
pub mod shlvl;
|
2020-02-26 16:18:19 +00:00
|
|
|
pub mod singularity;
|
2019-10-25 01:08:09 +00:00
|
|
|
mod starship_root;
|
2020-09-25 22:04:51 +00:00
|
|
|
pub mod status;
|
2020-07-29 15:36:49 +00:00
|
|
|
pub mod swift;
|
2019-12-09 01:42:51 +00:00
|
|
|
pub mod terraform;
|
2019-10-05 15:07:00 +00:00
|
|
|
pub mod time;
|
2019-10-19 01:51:38 +00:00
|
|
|
pub mod username;
|
2021-05-03 19:50:29 +00:00
|
|
|
pub mod v;
|
2021-01-30 11:05:16 +00:00
|
|
|
pub mod vagrant;
|
2021-03-28 15:48:15 +00:00
|
|
|
pub mod vcsh;
|
2020-05-21 16:49:49 +00:00
|
|
|
pub mod zig;
|
2019-09-30 12:10:35 +00:00
|
|
|
|
2019-10-25 01:08:09 +00:00
|
|
|
pub use starship_root::*;
|
2021-03-31 15:31:55 +00:00
|
|
|
|
2021-04-26 17:55:22 +00:00
|
|
|
#[derive(Serialize, ModuleConfig, Clone)]
|
2021-03-31 15:31:55 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub struct FullConfig<'a> {
|
2021-04-05 14:47:49 +00:00
|
|
|
// Root config
|
|
|
|
pub format: &'a str,
|
|
|
|
pub scan_timeout: u64,
|
|
|
|
pub command_timeout: u64,
|
|
|
|
pub add_newline: bool,
|
|
|
|
// modules
|
2021-03-31 15:31:55 +00:00
|
|
|
aws: aws::AwsConfig<'a>,
|
2021-07-30 17:33:59 +00:00
|
|
|
battery: battery::BatteryConfig<'a>,
|
2021-03-31 15:31:55 +00:00
|
|
|
character: character::CharacterConfig<'a>,
|
|
|
|
cmake: cmake::CMakeConfig<'a>,
|
|
|
|
cmd_duration: cmd_duration::CmdDurationConfig<'a>,
|
|
|
|
conda: conda::CondaConfig<'a>,
|
|
|
|
crystal: crystal::CrystalConfig<'a>,
|
|
|
|
dart: dart::DartConfig<'a>,
|
2021-04-15 13:22:12 +00:00
|
|
|
deno: deno::DenoConfig<'a>,
|
2021-03-31 15:31:55 +00:00
|
|
|
directory: directory::DirectoryConfig<'a>,
|
|
|
|
docker_context: docker_context::DockerContextConfig<'a>,
|
|
|
|
dotnet: dotnet::DotnetConfig<'a>,
|
|
|
|
elixir: elixir::ElixirConfig<'a>,
|
|
|
|
elm: elm::ElmConfig<'a>,
|
2021-07-13 21:06:08 +00:00
|
|
|
env_var: IndexMap<String, env_var::EnvVarConfig<'a>>,
|
2021-03-31 15:31:55 +00:00
|
|
|
erlang: erlang::ErlangConfig<'a>,
|
|
|
|
gcloud: gcloud::GcloudConfig<'a>,
|
|
|
|
git_branch: git_branch::GitBranchConfig<'a>,
|
|
|
|
git_commit: git_commit::GitCommitConfig<'a>,
|
2021-07-10 20:54:34 +00:00
|
|
|
git_metrics: git_metrics::GitMetricsConfig<'a>,
|
2021-03-31 15:31:55 +00:00
|
|
|
git_state: git_state::GitStateConfig<'a>,
|
|
|
|
git_status: git_status::GitStatusConfig<'a>,
|
2021-04-05 14:47:49 +00:00
|
|
|
golang: go::GoConfig<'a>,
|
2021-03-31 15:31:55 +00:00
|
|
|
helm: helm::HelmConfig<'a>,
|
|
|
|
hg_branch: hg_branch::HgBranchConfig<'a>,
|
|
|
|
hostname: hostname::HostnameConfig<'a>,
|
|
|
|
java: java::JavaConfig<'a>,
|
|
|
|
jobs: jobs::JobsConfig<'a>,
|
|
|
|
julia: julia::JuliaConfig<'a>,
|
|
|
|
kotlin: kotlin::KotlinConfig<'a>,
|
|
|
|
kubernetes: kubernetes::KubernetesConfig<'a>,
|
2021-07-30 17:33:59 +00:00
|
|
|
line_break: line_break::LineBreakConfig,
|
2021-03-31 15:31:55 +00:00
|
|
|
lua: lua::LuaConfig<'a>,
|
|
|
|
memory_usage: memory_usage::MemoryConfig<'a>,
|
|
|
|
nim: nim::NimConfig<'a>,
|
|
|
|
nix_shell: nix_shell::NixShellConfig<'a>,
|
|
|
|
nodejs: nodejs::NodejsConfig<'a>,
|
|
|
|
ocaml: ocaml::OCamlConfig<'a>,
|
|
|
|
openstack: openstack::OspConfig<'a>,
|
|
|
|
package: package::PackageConfig<'a>,
|
|
|
|
perl: perl::PerlConfig<'a>,
|
|
|
|
php: php::PhpConfig<'a>,
|
|
|
|
purescript: purescript::PureScriptConfig<'a>,
|
|
|
|
python: python::PythonConfig<'a>,
|
2021-04-20 16:31:47 +00:00
|
|
|
red: red::RedConfig<'a>,
|
2021-07-30 17:33:59 +00:00
|
|
|
rlang: rlang::RLangConfig<'a>,
|
2021-03-31 15:31:55 +00:00
|
|
|
ruby: ruby::RubyConfig<'a>,
|
|
|
|
rust: rust::RustConfig<'a>,
|
|
|
|
scala: scala::ScalaConfig<'a>,
|
|
|
|
shell: shell::ShellConfig<'a>,
|
|
|
|
shlvl: shlvl::ShLvlConfig<'a>,
|
|
|
|
singularity: singularity::SingularityConfig<'a>,
|
|
|
|
status: status::StatusConfig<'a>,
|
|
|
|
swift: swift::SwiftConfig<'a>,
|
|
|
|
terraform: terraform::TerraformConfig<'a>,
|
|
|
|
time: time::TimeConfig<'a>,
|
|
|
|
username: username::UsernameConfig<'a>,
|
|
|
|
vagrant: vagrant::VagrantConfig<'a>,
|
2021-07-30 17:33:59 +00:00
|
|
|
vcsh: vcsh::VcshConfig<'a>,
|
|
|
|
vlang: v::VConfig<'a>,
|
2021-03-31 15:31:55 +00:00
|
|
|
zig: zig::ZigConfig<'a>,
|
|
|
|
custom: IndexMap<String, custom::CustomConfig<'a>>,
|
|
|
|
}
|
2021-04-26 17:55:22 +00:00
|
|
|
|
|
|
|
impl<'a> Default for FullConfig<'a> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
format: "$all",
|
|
|
|
scan_timeout: 30,
|
|
|
|
command_timeout: 500,
|
|
|
|
add_newline: true,
|
|
|
|
|
|
|
|
aws: Default::default(),
|
|
|
|
battery: Default::default(),
|
|
|
|
character: Default::default(),
|
|
|
|
cmake: Default::default(),
|
|
|
|
cmd_duration: Default::default(),
|
|
|
|
conda: Default::default(),
|
|
|
|
crystal: Default::default(),
|
|
|
|
dart: Default::default(),
|
|
|
|
deno: Default::default(),
|
|
|
|
directory: Default::default(),
|
|
|
|
docker_context: Default::default(),
|
|
|
|
dotnet: Default::default(),
|
|
|
|
elixir: Default::default(),
|
|
|
|
elm: Default::default(),
|
|
|
|
env_var: Default::default(),
|
|
|
|
erlang: Default::default(),
|
|
|
|
gcloud: Default::default(),
|
|
|
|
git_branch: Default::default(),
|
|
|
|
git_commit: Default::default(),
|
2021-07-10 20:54:34 +00:00
|
|
|
git_metrics: Default::default(),
|
2021-04-26 17:55:22 +00:00
|
|
|
git_state: Default::default(),
|
|
|
|
git_status: Default::default(),
|
|
|
|
golang: Default::default(),
|
|
|
|
helm: Default::default(),
|
|
|
|
hg_branch: Default::default(),
|
|
|
|
hostname: Default::default(),
|
|
|
|
java: Default::default(),
|
|
|
|
jobs: Default::default(),
|
|
|
|
julia: Default::default(),
|
|
|
|
kotlin: Default::default(),
|
|
|
|
kubernetes: Default::default(),
|
2021-07-30 17:33:59 +00:00
|
|
|
line_break: Default::default(),
|
2021-04-26 17:55:22 +00:00
|
|
|
lua: Default::default(),
|
|
|
|
memory_usage: Default::default(),
|
|
|
|
nim: Default::default(),
|
|
|
|
nix_shell: Default::default(),
|
|
|
|
nodejs: Default::default(),
|
|
|
|
ocaml: Default::default(),
|
|
|
|
openstack: Default::default(),
|
|
|
|
package: Default::default(),
|
|
|
|
perl: Default::default(),
|
|
|
|
php: Default::default(),
|
|
|
|
purescript: Default::default(),
|
|
|
|
python: Default::default(),
|
2021-04-26 18:26:05 +00:00
|
|
|
red: Default::default(),
|
2021-05-25 18:13:30 +00:00
|
|
|
rlang: Default::default(),
|
2021-04-26 17:55:22 +00:00
|
|
|
ruby: Default::default(),
|
|
|
|
rust: Default::default(),
|
|
|
|
scala: Default::default(),
|
|
|
|
shell: Default::default(),
|
|
|
|
shlvl: Default::default(),
|
|
|
|
singularity: Default::default(),
|
|
|
|
status: Default::default(),
|
|
|
|
swift: Default::default(),
|
|
|
|
terraform: Default::default(),
|
|
|
|
time: Default::default(),
|
|
|
|
username: Default::default(),
|
|
|
|
vagrant: Default::default(),
|
2021-07-30 17:33:59 +00:00
|
|
|
vcsh: Default::default(),
|
2021-05-03 19:50:29 +00:00
|
|
|
vlang: Default::default(),
|
2021-04-26 17:55:22 +00:00
|
|
|
zig: Default::default(),
|
|
|
|
custom: Default::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-30 17:33:59 +00:00
|
|
|
|
|
|
|
#[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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|