mirror of
https://github.com/nushell/nushell
synced 2025-01-11 20:59:08 +00:00
add from bool for use ansi coloring
This commit is contained in:
parent
f32828625e
commit
146ffe49d0
1 changed files with 10 additions and 4 deletions
|
@ -45,13 +45,19 @@ impl UseAnsiColoring {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<bool> for UseAnsiColoring {
|
||||||
|
fn from(value: bool) -> Self {
|
||||||
|
match value {
|
||||||
|
true => Self::True,
|
||||||
|
false => Self::False,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromValue for UseAnsiColoring {
|
impl FromValue for UseAnsiColoring {
|
||||||
fn from_value(v: Value) -> Result<Self, ShellError> {
|
fn from_value(v: Value) -> Result<Self, ShellError> {
|
||||||
if let Ok(v) = v.as_bool() {
|
if let Ok(v) = v.as_bool() {
|
||||||
return Ok(match v {
|
return Ok(v.into());
|
||||||
true => Self::True,
|
|
||||||
false => Self::False,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(FromValue)]
|
#[derive(FromValue)]
|
||||||
|
|
Loading…
Reference in a new issue