From cd50b354a3ce11b0cffa140bb98cfe3ac87137a2 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Mon, 26 Apr 2021 19:55:22 +0200 Subject: [PATCH] fix(print-config): use proper defaults for top-level values (#2605) --- src/configs/mod.rs | 70 +++++++++++++++++++++++++++++++++++- src/configs/starship_root.rs | 1 + 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/configs/mod.rs b/src/configs/mod.rs index 1204bd87..1a1ddcc3 100644 --- a/src/configs/mod.rs +++ b/src/configs/mod.rs @@ -65,7 +65,7 @@ pub mod zig; pub use starship_root::*; -#[derive(Default, Serialize, ModuleConfig, Clone)] +#[derive(Serialize, ModuleConfig, Clone)] #[serde(default)] pub struct FullConfig<'a> { // Root config @@ -132,3 +132,71 @@ pub struct FullConfig<'a> { zig: zig::ZigConfig<'a>, custom: IndexMap>, } + +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(), + 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(), + 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(), + 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(), + zig: Default::default(), + custom: Default::default(), + } + } +} diff --git a/src/configs/starship_root.rs b/src/configs/starship_root.rs index b04d0cfe..50c206c0 100644 --- a/src/configs/starship_root.rs +++ b/src/configs/starship_root.rs @@ -81,6 +81,7 @@ pub const PROMPT_ORDER: &[&str] = &[ "character", ]; +// On changes please also update `Default` for the `FullConfig` struct in `mod.rs` impl<'a> Default for StarshipRootConfig<'a> { fn default() -> Self { StarshipRootConfig {