nu_protocol/config/
output.rs1use super::{config_update_string_enum, prelude::*};
2
3use crate::{self as nu_protocol};
4
5#[derive(Clone, Copy, Debug, IntoValue, PartialEq, Eq, Serialize, Deserialize)]
6pub enum ErrorStyle {
7 Plain,
8 Fancy,
9}
10
11impl FromStr for ErrorStyle {
12 type Err = &'static str;
13
14 fn from_str(s: &str) -> Result<Self, Self::Err> {
15 match s.to_ascii_lowercase().as_str() {
16 "fancy" => Ok(Self::Fancy),
17 "plain" => Ok(Self::Plain),
18 _ => Err("'fancy' or 'plain'"),
19 }
20 }
21}
22
23impl UpdateFromValue for ErrorStyle {
24 fn update(&mut self, value: &Value, path: &mut ConfigPath, errors: &mut ConfigErrors) {
25 config_update_string_enum(self, value, path, errors)
26 }
27}