Skip to content

Commit

Permalink
fix(print-config): fix battery module and add missing modules (starsh…
Browse files Browse the repository at this point in the history
…ip#2930)

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

* sort, add test, add line_break module
  • Loading branch information
davidkna authored Jul 30, 2021
1 parent dc1c974 commit b085387
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/configs/line_break.rs
Original file line number Diff line number Diff line change
@@ -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 }
}
}
27 changes: 24 additions & 3 deletions src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub mod jobs;
pub mod julia;
pub mod kotlin;
pub mod kubernetes;
pub mod line_break;
pub mod lua;
pub mod memory_usage;
pub mod nim;
Expand Down Expand Up @@ -78,7 +79,7 @@ pub struct FullConfig<'a> {
pub add_newline: bool,
// modules
aws: aws::AwsConfig<'a>,
battery: battery::BatteryDisplayConfig<'a>,
battery: battery::BatteryConfig<'a>,
character: character::CharacterConfig<'a>,
cmake: cmake::CMakeConfig<'a>,
cmd_duration: cmd_duration::CmdDurationConfig<'a>,
Expand Down Expand Up @@ -108,6 +109,7 @@ pub struct FullConfig<'a> {
julia: julia::JuliaConfig<'a>,
kotlin: kotlin::KotlinConfig<'a>,
kubernetes: kubernetes::KubernetesConfig<'a>,
line_break: line_break::LineBreakConfig,
lua: lua::LuaConfig<'a>,
memory_usage: memory_usage::MemoryConfig<'a>,
nim: nim::NimConfig<'a>,
Expand All @@ -120,8 +122,8 @@ pub struct FullConfig<'a> {
php: php::PhpConfig<'a>,
purescript: purescript::PureScriptConfig<'a>,
python: python::PythonConfig<'a>,
rlang: rlang::RLangConfig<'a>,
red: red::RedConfig<'a>,
rlang: rlang::RLangConfig<'a>,
ruby: ruby::RubyConfig<'a>,
rust: rust::RustConfig<'a>,
scala: scala::ScalaConfig<'a>,
Expand All @@ -133,8 +135,9 @@ pub struct FullConfig<'a> {
terraform: terraform::TerraformConfig<'a>,
time: time::TimeConfig<'a>,
username: username::UsernameConfig<'a>,
vlang: v::VConfig<'a>,
vagrant: vagrant::VagrantConfig<'a>,
vcsh: vcsh::VcshConfig<'a>,
vlang: v::VConfig<'a>,
zig: zig::ZigConfig<'a>,
custom: IndexMap<String, custom::CustomConfig<'a>>,
}
Expand Down Expand Up @@ -178,6 +181,7 @@ impl<'a> Default for FullConfig<'a> {
julia: Default::default(),
kotlin: Default::default(),
kubernetes: Default::default(),
line_break: Default::default(),
lua: Default::default(),
memory_usage: Default::default(),
nim: Default::default(),
Expand All @@ -204,9 +208,26 @@ impl<'a> Default for FullConfig<'a> {
time: Default::default(),
username: Default::default(),
vagrant: Default::default(),
vcsh: Default::default(),
vlang: Default::default(),
zig: 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));
}
}
}
3 changes: 2 additions & 1 deletion src/configs/vcsh.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::config::ModuleConfig;

use serde::Serialize;
use starship_module_config_derive::ModuleConfig;

#[derive(Clone, ModuleConfig)]
#[derive(Clone, ModuleConfig, Serialize)]
pub struct VcshConfig<'a> {
pub symbol: &'a str,
pub style: &'a str,
Expand Down

0 comments on commit b085387

Please sign in to comment.