mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 21:57:41 +00:00
feat(conda): add ignore_base option (#1539)
* Add ignore_base to conda module * Add ignore_base to conda module in English docs * `ignore_base` defaults to `true`
This commit is contained in:
parent
fbaeef8589
commit
acefbc523f
@ -519,6 +519,7 @@ This does not suppress conda's own prompt modifier, you may want to run `conda c
|
||||
| `symbol` | `"🅒 "` | The symbol used before the environment name. |
|
||||
| `style` | `"bold green"` | The style for the module. |
|
||||
| `format` | `"[$symbol$environment]($style) "` | The format for the module. |
|
||||
| `ignore_base` | `true` | Ignores `base` environment when activated. |
|
||||
| `disabled` | `false` | Disables the `conda` module. |
|
||||
|
||||
### Variables
|
||||
|
@ -8,6 +8,7 @@ pub struct CondaConfig<'a> {
|
||||
pub format: &'a str,
|
||||
pub symbol: &'a str,
|
||||
pub style: &'a str,
|
||||
pub ignore_base: bool,
|
||||
pub disabled: bool,
|
||||
}
|
||||
|
||||
@ -18,6 +19,7 @@ impl<'a> RootModuleConfig<'a> for CondaConfig<'a> {
|
||||
format: "via [$symbol$environment]($style) ",
|
||||
symbol: "🅒 ",
|
||||
style: "green bold",
|
||||
ignore_base: true,
|
||||
disabled: false,
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
let mut module = context.new_module("conda");
|
||||
let config: CondaConfig = CondaConfig::try_load(module.config);
|
||||
|
||||
if config.ignore_base && conda_env == "base" {
|
||||
return None;
|
||||
}
|
||||
|
||||
let conda_env = truncate(conda_env, config.truncation_length);
|
||||
|
||||
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use ansi_term::Color;
|
||||
use std::io;
|
||||
|
||||
use crate::common;
|
||||
use crate::common::{self, TestCommand};
|
||||
|
||||
#[test]
|
||||
fn not_in_env() -> io::Result<()> {
|
||||
@ -14,6 +14,23 @@ fn not_in_env() -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_base() -> io::Result<()> {
|
||||
let output = common::render_module("conda")
|
||||
.env("CONDA_DEFAULT_ENV", "base")
|
||||
.use_config(toml::toml! {
|
||||
[conda]
|
||||
ignore_base = true
|
||||
})
|
||||
.output()?;
|
||||
|
||||
let expected = "";
|
||||
let actual = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn env_set() -> io::Result<()> {
|
||||
let output = common::render_module("conda")
|
||||
|
Loading…
Reference in New Issue
Block a user