diff options
author | Matan Kushner <hello@matchai.me> | 2019-07-02 16:12:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 16:12:53 -0400 |
commit | 463ec260247fa0e62d2ea14e237681a499955392 (patch) | |
tree | 0d7ed8d19187c298c2e7764f21387a919d21877c /src/modules/package.rs | |
parent | 2440ed60d0a315e6248c040d2a114f7deeea6260 (diff) |
feat: Add a `disabled` configuration option for modules (#86)
• Add support for the disabled configuration option
This will allow you to selectively disable modules that you don't want or need. 😄
• Overwrite starship configuration file path with STARSHIP_CONFIG environment variable
• Write tests for the two configuration options that are available
Diffstat (limited to 'src/modules/package.rs')
-rw-r--r-- | src/modules/package.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/modules/package.rs b/src/modules/package.rs index a9af63891..527d5eaec 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -8,13 +8,13 @@ use toml; /// Creates a segment with the current package version /// /// Will display if a version is defined for your Node.js or Rust project (if one exists) -pub fn segment<'a>(context: &'a Context) -> Option<Module<'a>> { +pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { match get_package_version() { Some(package_version) => { const PACKAGE_CHAR: &str = "📦 "; let module_color = Color::Red.bold(); - let mut module = context.new_module("package"); + let mut module = context.new_module("package")?; module.set_style(module_color); module.get_prefix().set_value("is "); @@ -75,19 +75,21 @@ mod tests { #[test] fn test_extract_cargo_version() { - let cargo_with_version = r#" + let cargo_with_version = toml::toml! { [package] name = "starship" version = "0.1.0" - "#; + } + .to_string(); let expected_version = Some("v0.1.0".to_string()); assert_eq!(extract_cargo_version(&cargo_with_version), expected_version); - let cargo_without_version = r#" + let cargo_without_version = toml::toml! { [package] name = "starship" - "#; + } + .to_string(); let expected_version = None; assert_eq!( |