1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-24 21:57:41 +00:00

fix(print-config): fix battery module and add missing modules (#2930)

* fix(print-config): fix battery and vcsh module handling

* sort, add test, add line_break module
This commit is contained in:
David Knaack 2021-07-30 19:33:59 +02:00 committed by GitHub
parent dc1c974287
commit b0853876ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 4 deletions

15
src/configs/line_break.rs Normal file
View File

@ -0,0 +1,15 @@
use crate::config::ModuleConfig;
use serde::Serialize;
use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig, Serialize)]
pub struct LineBreakConfig {
pub disabled: bool,
}
impl<'a> Default for LineBreakConfig {
fn default() -> Self {
LineBreakConfig { disabled: false }
}
}

View File

@ -35,6 +35,7 @@ pub mod jobs;
pub mod julia; pub mod julia;
pub mod kotlin; pub mod kotlin;
pub mod kubernetes; pub mod kubernetes;
pub mod line_break;
pub mod lua; pub mod lua;
pub mod memory_usage; pub mod memory_usage;
pub mod nim; pub mod nim;
@ -78,7 +79,7 @@ pub struct FullConfig<'a> {
pub add_newline: bool, pub add_newline: bool,
// modules // modules
aws: aws::AwsConfig<'a>, aws: aws::AwsConfig<'a>,
battery: battery::BatteryDisplayConfig<'a>, battery: battery::BatteryConfig<'a>,
character: character::CharacterConfig<'a>, character: character::CharacterConfig<'a>,
cmake: cmake::CMakeConfig<'a>, cmake: cmake::CMakeConfig<'a>,
cmd_duration: cmd_duration::CmdDurationConfig<'a>, cmd_duration: cmd_duration::CmdDurationConfig<'a>,
@ -108,6 +109,7 @@ pub struct FullConfig<'a> {
julia: julia::JuliaConfig<'a>, julia: julia::JuliaConfig<'a>,
kotlin: kotlin::KotlinConfig<'a>, kotlin: kotlin::KotlinConfig<'a>,
kubernetes: kubernetes::KubernetesConfig<'a>, kubernetes: kubernetes::KubernetesConfig<'a>,
line_break: line_break::LineBreakConfig,
lua: lua::LuaConfig<'a>, lua: lua::LuaConfig<'a>,
memory_usage: memory_usage::MemoryConfig<'a>, memory_usage: memory_usage::MemoryConfig<'a>,
nim: nim::NimConfig<'a>, nim: nim::NimConfig<'a>,
@ -120,8 +122,8 @@ pub struct FullConfig<'a> {
php: php::PhpConfig<'a>, php: php::PhpConfig<'a>,
purescript: purescript::PureScriptConfig<'a>, purescript: purescript::PureScriptConfig<'a>,
python: python::PythonConfig<'a>, python: python::PythonConfig<'a>,
rlang: rlang::RLangConfig<'a>,
red: red::RedConfig<'a>, red: red::RedConfig<'a>,
rlang: rlang::RLangConfig<'a>,
ruby: ruby::RubyConfig<'a>, ruby: ruby::RubyConfig<'a>,
rust: rust::RustConfig<'a>, rust: rust::RustConfig<'a>,
scala: scala::ScalaConfig<'a>, scala: scala::ScalaConfig<'a>,
@ -133,8 +135,9 @@ pub struct FullConfig<'a> {
terraform: terraform::TerraformConfig<'a>, terraform: terraform::TerraformConfig<'a>,
time: time::TimeConfig<'a>, time: time::TimeConfig<'a>,
username: username::UsernameConfig<'a>, username: username::UsernameConfig<'a>,
vlang: v::VConfig<'a>,
vagrant: vagrant::VagrantConfig<'a>, vagrant: vagrant::VagrantConfig<'a>,
vcsh: vcsh::VcshConfig<'a>,
vlang: v::VConfig<'a>,
zig: zig::ZigConfig<'a>, zig: zig::ZigConfig<'a>,
custom: IndexMap<String, custom::CustomConfig<'a>>, custom: IndexMap<String, custom::CustomConfig<'a>>,
} }
@ -178,6 +181,7 @@ impl<'a> Default for FullConfig<'a> {
julia: Default::default(), julia: Default::default(),
kotlin: Default::default(), kotlin: Default::default(),
kubernetes: Default::default(), kubernetes: Default::default(),
line_break: Default::default(),
lua: Default::default(), lua: Default::default(),
memory_usage: Default::default(), memory_usage: Default::default(),
nim: Default::default(), nim: Default::default(),
@ -204,9 +208,26 @@ impl<'a> Default for FullConfig<'a> {
time: Default::default(), time: Default::default(),
username: Default::default(), username: Default::default(),
vagrant: Default::default(), vagrant: Default::default(),
vcsh: Default::default(),
vlang: Default::default(), vlang: Default::default(),
zig: Default::default(), zig: Default::default(),
custom: Default::default(), custom: Default::default(),
} }
} }
} }
#[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));
}
}
}

View File

@ -1,8 +1,9 @@
use crate::config::ModuleConfig; use crate::config::ModuleConfig;
use serde::Serialize;
use starship_module_config_derive::ModuleConfig; use starship_module_config_derive::ModuleConfig;
#[derive(Clone, ModuleConfig)] #[derive(Clone, ModuleConfig, Serialize)]
pub struct VcshConfig<'a> { pub struct VcshConfig<'a> {
pub symbol: &'a str, pub symbol: &'a str,
pub style: &'a str, pub style: &'a str,