diff options
author | Zhenhui Xie <xiezh0831@yahoo.co.jp> | 2019-10-15 19:34:48 +0800 |
---|---|---|
committer | Matan Kushner <hello@matchai.me> | 2019-10-15 20:34:48 +0900 |
commit | be2d5cf1cd23d2b33892445f5d73dda5b165e7a7 (patch) | |
tree | b9296cd5c5ce94a1bc9b1ae7b4922b9c093ace92 /src/configs | |
parent | 2fd1920f7d59831ac5a50e03813caf834e9d65fe (diff) |
refactor: Rewrite cmd_duration, directory and env_var module to use module config (#460)
This PR is a batched rewrite of the following modules:
- cmd_duration
- directory
- env_var
Diffstat (limited to 'src/configs')
-rw-r--r-- | src/configs/cmd_duration.rs | 23 | ||||
-rw-r--r-- | src/configs/directory.rs | 27 | ||||
-rw-r--r-- | src/configs/env_var.rs | 29 | ||||
-rw-r--r-- | src/configs/mod.rs | 3 |
4 files changed, 82 insertions, 0 deletions
diff --git a/src/configs/cmd_duration.rs b/src/configs/cmd_duration.rs new file mode 100644 index 000000000..2cf7a85af --- /dev/null +++ b/src/configs/cmd_duration.rs @@ -0,0 +1,23 @@ +use crate::config::{ModuleConfig, RootModuleConfig}; + +use ansi_term::{Color, Style}; +use starship_module_config_derive::ModuleConfig; + +#[derive(Clone, ModuleConfig)] +pub struct CmdDurationConfig<'a> { + pub min_time: i64, + pub prefix: &'a str, + pub style: Style, + pub disabled: bool, +} + +impl<'a> RootModuleConfig<'a> for CmdDurationConfig<'a> { + fn new() -> Self { + CmdDurationConfig { + min_time: 2, + prefix: "took ", + style: Color::Yellow.bold(), + disabled: false, + } + } +} diff --git a/src/configs/directory.rs b/src/configs/directory.rs new file mode 100644 index 000000000..40574fd1d --- /dev/null +++ b/src/configs/directory.rs @@ -0,0 +1,27 @@ +use crate::config::{ModuleConfig, RootModuleConfig}; + +use ansi_term::{Color, Style}; +use starship_module_config_derive::ModuleConfig; + +#[derive(Clone, ModuleConfig)] +pub struct DirectoryConfig { + pub truncation_length: i64, + pub truncate_to_repo: bool, + pub fish_style_pwd_dir_length: i64, + pub use_logical_path: bool, + pub style: Style, + pub disabled: bool, +} + +impl<'a> RootModuleConfig<'a> for DirectoryConfig { + fn new() -> Self { + DirectoryConfig { + truncation_length: 3, + truncate_to_repo: true, + fish_style_pwd_dir_length: 0, + use_logical_path: true, + style: Color::Cyan.bold(), + disabled: false, + } + } +} diff --git a/src/configs/env_var.rs b/src/configs/env_var.rs new file mode 100644 index 000000000..fc4e6533f --- /dev/null +++ b/src/configs/env_var.rs @@ -0,0 +1,29 @@ +use crate::config::{ModuleConfig, RootModuleConfig, SegmentConfig}; + +use ansi_term::{Color, Style}; +use starship_module_config_derive::ModuleConfig; + +#[derive(Clone, ModuleConfig)] +pub struct EnvVarConfig<'a> { + pub symbol: Option<SegmentConfig<'a>>, + pub variable: Option<&'a str>, + pub default: Option<&'a str>, + pub prefix: &'a str, + pub suffix: &'a str, + pub style: Style, + pub disabled: bool, +} + +impl<'a> RootModuleConfig<'a> for EnvVarConfig<'a> { + fn new() -> Self { + EnvVarConfig { + symbol: None, + variable: None, + default: None, + prefix: "", + suffix: "", + style: Color::Black.bold().dimmed(), + disabled: false, + } + } +} diff --git a/src/configs/mod.rs b/src/configs/mod.rs index 40ed6293d..b26c1ebf9 100644 --- a/src/configs/mod.rs +++ b/src/configs/mod.rs @@ -1,8 +1,11 @@ pub mod aws; pub mod battery; pub mod character; +pub mod cmd_duration; pub mod conda; +pub mod directory; pub mod dotnet; +pub mod env_var; pub mod go; pub mod hostname; pub mod jobs; |