feat(config): allow printing default and computed config (#2521)
* feat: allow printing default and computed config * fix custom modules * actually fix custom modules
This commit is contained in:
parent
2b15ca1a15
commit
d06ba072a8
|
@ -694,6 +694,7 @@ checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1627,7 +1628,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "starship_module_config_derive"
|
name = "starship_module_config_derive"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote 1.0.9",
|
"quote 1.0.9",
|
||||||
|
|
|
@ -61,7 +61,7 @@ term_size = "0.3.2"
|
||||||
quick-xml = "0.22.0"
|
quick-xml = "0.22.0"
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
serde = { version = "1.0.125", features = ["derive"] }
|
serde = { version = "1.0.125", features = ["derive"] }
|
||||||
indexmap = "1.6.2"
|
indexmap = { version ="1.6.2", features = ["serde"] }
|
||||||
notify-rust = { version = "4.3.0", optional = true }
|
notify-rust = { version = "4.3.0", optional = true }
|
||||||
semver = "0.11.0"
|
semver = "0.11.0"
|
||||||
which = "4.1.0"
|
which = "4.1.0"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
To get started configuring starship, create the following file: `~/.config/starship.toml`.
|
To get started configuring starship, create the following file: `~/.config/starship.toml`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p ~/.config && touch ~/.config/starship.toml
|
mkdir -p ~/.config && starship print-config --default > ~/.config/starship.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
All configuration for starship is done in this [TOML](https://github.com/toml-lang/toml) file:
|
All configuration for starship is done in this [TOML](https://github.com/toml-lang/toml) file:
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::configs::StarshipRootConfig;
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
use ansi_term::{Color, Style};
|
use ansi_term::{Color, Style};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -174,7 +175,7 @@ where
|
||||||
|
|
||||||
/// A wrapper around `Vec<T>` that implements `ModuleConfig`, and either
|
/// A wrapper around `Vec<T>` that implements `ModuleConfig`, and either
|
||||||
/// accepts a value of type `T` or a list of values of type `T`.
|
/// accepts a value of type `T` or a list of values of type `T`.
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default, Serialize)]
|
||||||
pub struct VecOr<T>(pub Vec<T>);
|
pub struct VecOr<T>(pub Vec<T>);
|
||||||
|
|
||||||
impl<'a, T> ModuleConfig<'a> for VecOr<T>
|
impl<'a, T> ModuleConfig<'a> for VecOr<T>
|
||||||
|
@ -479,7 +480,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_config() {
|
fn test_load_config() {
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, Default, ModuleConfig)]
|
||||||
struct TestConfig<'a> {
|
struct TestConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
|
@ -505,13 +506,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_nested_config() {
|
fn test_load_nested_config() {
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, Default, ModuleConfig)]
|
||||||
struct TestConfig<'a> {
|
struct TestConfig<'a> {
|
||||||
pub untracked: SegmentDisplayConfig<'a>,
|
pub untracked: SegmentDisplayConfig<'a>,
|
||||||
pub modified: SegmentDisplayConfig<'a>,
|
pub modified: SegmentDisplayConfig<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone, ModuleConfig)]
|
#[derive(PartialEq, Debug, Clone, Default, ModuleConfig)]
|
||||||
struct SegmentDisplayConfig<'a> {
|
struct SegmentDisplayConfig<'a> {
|
||||||
pub value: &'a str,
|
pub value: &'a str,
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
|
@ -552,7 +553,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_optional_config() {
|
fn test_load_optional_config() {
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, Default, ModuleConfig)]
|
||||||
struct TestConfig<'a> {
|
struct TestConfig<'a> {
|
||||||
pub optional: Option<&'a str>,
|
pub optional: Option<&'a str>,
|
||||||
pub hidden: Option<&'a str>,
|
pub hidden: Option<&'a str>,
|
||||||
|
@ -573,7 +574,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_enum_config() {
|
fn test_load_enum_config() {
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, Default, ModuleConfig)]
|
||||||
struct TestConfig {
|
struct TestConfig {
|
||||||
pub switch_a: Switch,
|
pub switch_a: Switch,
|
||||||
pub switch_b: Switch,
|
pub switch_b: Switch,
|
||||||
|
@ -586,6 +587,12 @@ mod tests {
|
||||||
Off,
|
Off,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Switch {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Off
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> ModuleConfig<'a> for Switch {
|
impl<'a> ModuleConfig<'a> for Switch {
|
||||||
fn from_config(config: &'a Value) -> Option<Self> {
|
fn from_config(config: &'a Value) -> Option<Self> {
|
||||||
match config.as_str()? {
|
match config.as_str()? {
|
||||||
|
|
|
@ -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;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig, Serialize)]
|
||||||
pub struct AwsConfig<'a> {
|
pub struct AwsConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 BatteryConfig<'a> {
|
pub struct BatteryConfig<'a> {
|
||||||
pub full_symbol: &'a str,
|
pub full_symbol: &'a str,
|
||||||
pub charging_symbol: &'a str,
|
pub charging_symbol: &'a str,
|
||||||
|
@ -32,7 +33,7 @@ impl<'a> Default for BatteryConfig<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig, Default, Serialize)]
|
||||||
pub struct BatteryDisplayConfig<'a> {
|
pub struct BatteryDisplayConfig<'a> {
|
||||||
pub threshold: i64,
|
pub threshold: i64,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
|
|
@ -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 CharacterConfig<'a> {
|
pub struct CharacterConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub success_symbol: &'a str,
|
pub success_symbol: &'a str,
|
||||||
|
|
|
@ -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 CMakeConfig<'a> {
|
pub struct CMakeConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 CmdDurationConfig<'a> {
|
pub struct CmdDurationConfig<'a> {
|
||||||
pub min_time: i64,
|
pub min_time: i64,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 CondaConfig<'a> {
|
pub struct CondaConfig<'a> {
|
||||||
pub truncation_length: usize,
|
pub truncation_length: usize,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 CrystalConfig<'a> {
|
pub struct CrystalConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,29 +1,22 @@
|
||||||
use crate::config::{ModuleConfig, VecOr};
|
use crate::config::{ModuleConfig, VecOr};
|
||||||
|
|
||||||
|
use serde::{self, Serialize};
|
||||||
use starship_module_config_derive::ModuleConfig;
|
use starship_module_config_derive::ModuleConfig;
|
||||||
|
|
||||||
#[derive(Clone, Default, PartialEq)]
|
#[derive(Clone, ModuleConfig, Serialize)]
|
||||||
pub struct Files<'a>(pub Vec<&'a str>);
|
|
||||||
|
|
||||||
#[derive(Clone, Default, PartialEq)]
|
|
||||||
pub struct Extensions<'a>(pub Vec<&'a str>);
|
|
||||||
|
|
||||||
#[derive(Clone, Default, PartialEq)]
|
|
||||||
pub struct Directories<'a>(pub Vec<&'a str>);
|
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
|
||||||
pub struct CustomConfig<'a> {
|
pub struct CustomConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub command: &'a str,
|
pub command: &'a str,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub when: Option<&'a str>,
|
pub when: Option<&'a str>,
|
||||||
pub shell: VecOr<&'a str>,
|
pub shell: VecOr<&'a str>,
|
||||||
pub description: &'a str,
|
pub description: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
pub files: Files<'a>,
|
pub files: Vec<&'a str>,
|
||||||
pub extensions: Extensions<'a>,
|
pub extensions: Vec<&'a str>,
|
||||||
pub directories: Directories<'a>,
|
pub directories: Vec<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for CustomConfig<'a> {
|
impl<'a> Default for CustomConfig<'a> {
|
||||||
|
@ -37,57 +30,9 @@ impl<'a> Default for CustomConfig<'a> {
|
||||||
description: "<custom config>",
|
description: "<custom config>",
|
||||||
style: "green bold",
|
style: "green bold",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
files: Files::default(),
|
files: Vec::default(),
|
||||||
extensions: Extensions::default(),
|
extensions: Vec::default(),
|
||||||
directories: Directories::default(),
|
directories: Vec::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ModuleConfig<'a> for Files<'a> {
|
|
||||||
fn from_config(config: &'a toml::Value) -> Option<Self> {
|
|
||||||
let mut files = Vec::new();
|
|
||||||
|
|
||||||
for item in config.as_array()? {
|
|
||||||
if let Some(file) = item.as_str() {
|
|
||||||
files.push(file);
|
|
||||||
} else {
|
|
||||||
log::warn!("Unexpected file {:?}", item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(Files(files))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ModuleConfig<'a> for Extensions<'a> {
|
|
||||||
fn from_config(config: &'a toml::Value) -> Option<Self> {
|
|
||||||
let mut extensions = Vec::new();
|
|
||||||
|
|
||||||
for item in config.as_array()? {
|
|
||||||
if let Some(file) = item.as_str() {
|
|
||||||
extensions.push(file);
|
|
||||||
} else {
|
|
||||||
log::warn!("Unexpected extension {:?}", item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(Extensions(extensions))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ModuleConfig<'a> for Directories<'a> {
|
|
||||||
fn from_config(config: &'a toml::Value) -> Option<Self> {
|
|
||||||
let mut directories = Vec::new();
|
|
||||||
|
|
||||||
for item in config.as_array()? {
|
|
||||||
if let Some(file) = item.as_str() {
|
|
||||||
directories.push(file);
|
|
||||||
} else {
|
|
||||||
log::warn!("Unexpected directory {:?}", item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(Directories(directories))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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 DartConfig<'a> {
|
pub struct DartConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use crate::config::ModuleConfig;
|
use crate::config::ModuleConfig;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
use starship_module_config_derive::ModuleConfig;
|
use starship_module_config_derive::ModuleConfig;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig, Serialize)]
|
||||||
pub struct DirectoryConfig<'a> {
|
pub struct DirectoryConfig<'a> {
|
||||||
pub truncation_length: i64,
|
pub truncation_length: i64,
|
||||||
pub truncate_to_repo: bool,
|
pub truncate_to_repo: bool,
|
||||||
|
|
|
@ -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 DockerContextConfig<'a> {
|
pub struct DockerContextConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
|
|
@ -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 DotnetConfig<'a> {
|
pub struct DotnetConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 ElixirConfig<'a> {
|
pub struct ElixirConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 ElmConfig<'a> {
|
pub struct ElmConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
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 EnvVarConfig<'a> {
|
pub struct EnvVarConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub variable: Option<&'a str>,
|
pub variable: Option<&'a str>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub default: Option<&'a str>,
|
pub default: Option<&'a str>,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
|
|
|
@ -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 ErlangConfig<'a> {
|
pub struct ErlangConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig, Serialize)]
|
||||||
pub struct GcloudConfig<'a> {
|
pub struct GcloudConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 GitBranchConfig<'a> {
|
pub struct GitBranchConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 GitCommitConfig<'a> {
|
pub struct GitCommitConfig<'a> {
|
||||||
pub commit_hash_length: usize,
|
pub commit_hash_length: usize,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 GitStateConfig<'a> {
|
pub struct GitStateConfig<'a> {
|
||||||
pub rebase: &'a str,
|
pub rebase: &'a str,
|
||||||
pub merge: &'a str,
|
pub merge: &'a str,
|
||||||
|
|
|
@ -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 GitStatusConfig<'a> {
|
pub struct GitStatusConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
|
|
@ -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 GoConfig<'a> {
|
pub struct GoConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 HelmConfig<'a> {
|
pub struct HelmConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 HgBranchConfig<'a> {
|
pub struct HgBranchConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
|
|
@ -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 HostnameConfig<'a> {
|
pub struct HostnameConfig<'a> {
|
||||||
pub ssh_only: bool,
|
pub ssh_only: bool,
|
||||||
pub trim_at: &'a str,
|
pub trim_at: &'a str,
|
||||||
|
|
|
@ -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 JavaConfig<'a> {
|
pub struct JavaConfig<'a> {
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 JobsConfig<'a> {
|
pub struct JobsConfig<'a> {
|
||||||
pub threshold: i64,
|
pub threshold: i64,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 JuliaConfig<'a> {
|
pub struct JuliaConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 KotlinConfig<'a> {
|
pub struct KotlinConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use crate::config::ModuleConfig;
|
use crate::config::ModuleConfig;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
use starship_module_config_derive::ModuleConfig;
|
use starship_module_config_derive::ModuleConfig;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig, Serialize)]
|
||||||
pub struct KubernetesConfig<'a> {
|
pub struct KubernetesConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 LuaConfig<'a> {
|
pub struct LuaConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 MemoryConfig<'a> {
|
pub struct MemoryConfig<'a> {
|
||||||
pub threshold: i64,
|
pub threshold: i64,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
use crate::config::ModuleConfig;
|
||||||
|
use indexmap::IndexMap;
|
||||||
|
use serde::{self, Serialize};
|
||||||
|
use starship_module_config_derive::ModuleConfig;
|
||||||
|
|
||||||
pub mod aws;
|
pub mod aws;
|
||||||
pub mod battery;
|
pub mod battery;
|
||||||
pub mod character;
|
pub mod character;
|
||||||
|
@ -57,3 +62,65 @@ pub mod vcsh;
|
||||||
pub mod zig;
|
pub mod zig;
|
||||||
|
|
||||||
pub use starship_root::*;
|
pub use starship_root::*;
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, ModuleConfig, Clone)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct FullConfig<'a> {
|
||||||
|
#[serde(flatten)]
|
||||||
|
root: starship_root::StarshipRootConfig<'a>,
|
||||||
|
aws: aws::AwsConfig<'a>,
|
||||||
|
battery: battery::BatteryDisplayConfig<'a>,
|
||||||
|
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>,
|
||||||
|
directory: directory::DirectoryConfig<'a>,
|
||||||
|
docker_context: docker_context::DockerContextConfig<'a>,
|
||||||
|
dotnet: dotnet::DotnetConfig<'a>,
|
||||||
|
elixir: elixir::ElixirConfig<'a>,
|
||||||
|
elm: elm::ElmConfig<'a>,
|
||||||
|
env_var: env_var::EnvVarConfig<'a>,
|
||||||
|
erlang: erlang::ErlangConfig<'a>,
|
||||||
|
gcloud: gcloud::GcloudConfig<'a>,
|
||||||
|
git_branch: git_branch::GitBranchConfig<'a>,
|
||||||
|
git_commit: git_commit::GitCommitConfig<'a>,
|
||||||
|
git_state: git_state::GitStateConfig<'a>,
|
||||||
|
git_status: git_status::GitStatusConfig<'a>,
|
||||||
|
go: go::GoConfig<'a>,
|
||||||
|
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>,
|
||||||
|
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>,
|
||||||
|
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>,
|
||||||
|
zig: zig::ZigConfig<'a>,
|
||||||
|
custom: IndexMap<String, custom::CustomConfig<'a>>,
|
||||||
|
}
|
||||||
|
|
|
@ -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 NimConfig<'a> {
|
pub struct NimConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 NixShellConfig<'a> {
|
pub struct NixShellConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 NodejsConfig<'a> {
|
pub struct NodejsConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 OCamlConfig<'a> {
|
pub struct OCamlConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
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 OspConfig<'a> {
|
pub struct OspConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 PackageConfig<'a> {
|
pub struct PackageConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 PerlConfig<'a> {
|
pub struct PerlConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
|
|
@ -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 PhpConfig<'a> {
|
pub struct PhpConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
|
|
@ -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 PureScriptConfig<'a> {
|
pub struct PureScriptConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::config::{ModuleConfig, VecOr};
|
use crate::config::{ModuleConfig, VecOr};
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
use starship_module_config_derive::ModuleConfig;
|
use starship_module_config_derive::ModuleConfig;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig, Serialize)]
|
||||||
pub struct PythonConfig<'a> {
|
pub struct PythonConfig<'a> {
|
||||||
pub pyenv_version_name: bool,
|
pub pyenv_version_name: bool,
|
||||||
pub pyenv_prefix: &'a str,
|
pub pyenv_prefix: &'a str,
|
||||||
|
|
|
@ -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 RubyConfig<'a> {
|
pub struct RubyConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 RustConfig<'a> {
|
pub struct RustConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 ScalaConfig<'a> {
|
pub struct ScalaConfig<'a> {
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 ShellConfig<'a> {
|
pub struct ShellConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub bash_indicator: &'a str,
|
pub bash_indicator: &'a str,
|
||||||
|
|
|
@ -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 ShLvlConfig<'a> {
|
pub struct ShLvlConfig<'a> {
|
||||||
pub threshold: i64,
|
pub threshold: i64,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 SingularityConfig<'a> {
|
pub struct SingularityConfig<'a> {
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
|
|
|
@ -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 StarshipRootConfig<'a> {
|
pub struct StarshipRootConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub scan_timeout: u64,
|
pub scan_timeout: u64,
|
||||||
|
|
|
@ -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 StatusConfig<'a> {
|
pub struct StatusConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 SwiftConfig<'a> {
|
pub struct SwiftConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 TerraformConfig<'a> {
|
pub struct TerraformConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
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 TimeConfig<'a> {
|
pub struct TimeConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
pub use_12hr: bool,
|
pub use_12hr: bool,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub time_format: Option<&'a str>,
|
pub time_format: Option<&'a str>,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
pub utc_time_offset: &'a str,
|
pub utc_time_offset: &'a str,
|
||||||
|
|
|
@ -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 UsernameConfig<'a> {
|
pub struct UsernameConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub style_root: &'a str,
|
pub style_root: &'a str,
|
||||||
|
|
|
@ -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 VagrantConfig<'a> {
|
pub struct VagrantConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -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 ZigConfig<'a> {
|
pub struct ZigConfig<'a> {
|
||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub symbol: &'a str,
|
pub symbol: &'a str,
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::io::ErrorKind;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
use crate::config::RootModuleConfig;
|
||||||
use crate::config::StarshipConfig;
|
use crate::config::StarshipConfig;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -52,6 +53,27 @@ pub fn update_configuration(name: &str, value: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn print_configuration(use_default: bool) {
|
||||||
|
let config = if use_default {
|
||||||
|
// Get default config
|
||||||
|
let default_config = crate::configs::FullConfig::default();
|
||||||
|
// Convert back to Value because toml can't serialize FullConfig directly
|
||||||
|
toml::value::Value::try_from(default_config).unwrap()
|
||||||
|
} else {
|
||||||
|
// Get config as toml::Value
|
||||||
|
let user_config = get_configuration();
|
||||||
|
// Convert into FullConfig and fill in default values
|
||||||
|
let user_config = crate::configs::FullConfig::try_load(Some(&user_config));
|
||||||
|
// Convert back to Value because toml can't serialize FullConfig directly
|
||||||
|
toml::value::Value::try_from(user_config).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
|
let string_config = toml::to_string_pretty(&config).unwrap();
|
||||||
|
|
||||||
|
println!("# Warning: This config does not include keys that have an unset value");
|
||||||
|
println!("{}", string_config);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn toggle_configuration(name: &str, key: &str) {
|
pub fn toggle_configuration(name: &str, key: &str) {
|
||||||
if let Some(table) = get_configuration().as_table_mut() {
|
if let Some(table) = get_configuration().as_table_mut() {
|
||||||
match table.get(name) {
|
match table.get(name) {
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -131,6 +131,17 @@ fn main() {
|
||||||
)
|
)
|
||||||
.arg(Arg::with_name("value").help("Value to place into that key")),
|
.arg(Arg::with_name("value").help("Value to place into that key")),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("print-config")
|
||||||
|
.about("Prints the computed starship configuration")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("default")
|
||||||
|
.short("d")
|
||||||
|
.long("default")
|
||||||
|
.help("Print the default instead of the computed config")
|
||||||
|
.takes_value(false),
|
||||||
|
),
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("toggle")
|
SubCommand::with_name("toggle")
|
||||||
.about("Toggle a given starship module")
|
.about("Toggle a given starship module")
|
||||||
|
@ -208,6 +219,10 @@ fn main() {
|
||||||
configure::edit_configuration()
|
configure::edit_configuration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
("print-config", Some(sub_m)) => {
|
||||||
|
let print_default = sub_m.is_present("default");
|
||||||
|
configure::print_configuration(print_default)
|
||||||
|
}
|
||||||
("toggle", Some(sub_m)) => {
|
("toggle", Some(sub_m)) => {
|
||||||
if let Some(name) = sub_m.value_of("name") {
|
if let Some(name) = sub_m.value_of("name") {
|
||||||
if let Some(value) = sub_m.value_of("key") {
|
if let Some(value) = sub_m.value_of("key") {
|
||||||
|
|
|
@ -20,19 +20,12 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option<Module<'a>> {
|
||||||
);
|
);
|
||||||
let config = CustomConfig::load(toml_config);
|
let config = CustomConfig::load(toml_config);
|
||||||
|
|
||||||
let mut scan_dir = context.try_begin_scan()?;
|
let mut is_match = context
|
||||||
|
.try_begin_scan()?
|
||||||
if !config.files.0.is_empty() {
|
.set_files(&config.files)
|
||||||
scan_dir = scan_dir.set_files(&config.files.0);
|
.set_extensions(&config.extensions)
|
||||||
}
|
.set_folders(&config.directories)
|
||||||
if !config.extensions.0.is_empty() {
|
.is_match();
|
||||||
scan_dir = scan_dir.set_extensions(&config.extensions.0);
|
|
||||||
}
|
|
||||||
if !config.directories.0.is_empty() {
|
|
||||||
scan_dir = scan_dir.set_folders(&config.directories.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut is_match = scan_dir.is_match();
|
|
||||||
|
|
||||||
if !is_match {
|
if !is_match {
|
||||||
if let Some(when) = config.when {
|
if let Some(when) = config.when {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "starship_module_config_derive"
|
name = "starship_module_config_derive"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
authors = ["Matan Kushner <hello@matchai.me>"]
|
authors = ["Matan Kushner <hello@matchai.me>"]
|
||||||
homepage = "https://starship.rs"
|
homepage = "https://starship.rs"
|
||||||
|
|
|
@ -18,29 +18,20 @@ fn impl_module_config(dinput: DeriveInput) -> proc_macro::TokenStream {
|
||||||
if let syn::Data::Struct(data) = dinput.data {
|
if let syn::Data::Struct(data) = dinput.data {
|
||||||
if let syn::Fields::Named(fields_named) = data.fields {
|
if let syn::Fields::Named(fields_named) = data.fields {
|
||||||
let mut load_tokens = quote! {};
|
let mut load_tokens = quote! {};
|
||||||
let mut from_tokens = quote! {};
|
|
||||||
|
|
||||||
for field in fields_named.named.iter() {
|
for field in fields_named.named.iter() {
|
||||||
let ident = field.ident.as_ref().unwrap();
|
let ident = field.ident.as_ref().unwrap();
|
||||||
let ty = &field.ty;
|
|
||||||
|
|
||||||
let new_load_tokens = quote! {
|
let new_load_tokens = quote! {
|
||||||
if let Some(config_str) = config.get(stringify!(#ident)) {
|
if let Some(config_str) = config.get(stringify!(#ident)) {
|
||||||
new_module_config.#ident = new_module_config.#ident.load_config(config_str);
|
new_module_config.#ident = new_module_config.#ident.load_config(config_str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let new_from_tokens = quote! {
|
|
||||||
#ident: config.get(stringify!(#ident)).and_then(<#ty>::from_config)?,
|
|
||||||
};
|
|
||||||
|
|
||||||
load_tokens = quote! {
|
load_tokens = quote! {
|
||||||
#load_tokens
|
#load_tokens
|
||||||
#new_load_tokens
|
#new_load_tokens
|
||||||
};
|
};
|
||||||
from_tokens = quote! {
|
|
||||||
#from_tokens
|
|
||||||
#new_from_tokens
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
load_config = quote! {
|
load_config = quote! {
|
||||||
|
@ -60,11 +51,7 @@ fn impl_module_config(dinput: DeriveInput) -> proc_macro::TokenStream {
|
||||||
};
|
};
|
||||||
from_config = quote! {
|
from_config = quote! {
|
||||||
fn from_config(config: &'a toml::Value) -> Option<Self> {
|
fn from_config(config: &'a toml::Value) -> Option<Self> {
|
||||||
let config = config.as_table()?;
|
Some(Self::default().load_config(config))
|
||||||
|
|
||||||
Some(#struct_ident {
|
|
||||||
#from_tokens
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue