nu_protocol/config/
status_line.rs1use super::prelude::*;
2use crate as nu_protocol;
3
4#[derive(Clone, Copy, Debug, IntoValue, PartialEq, Eq, Serialize, Deserialize)]
7pub struct StatusLineConfig {
8 pub enable: bool,
10 pub errors: bool,
12 pub signature: bool,
14 #[nu_value(rename = "type")]
16 #[serde(rename = "type")]
17 pub output_type: bool,
18 pub preview: bool,
20}
21
22impl Default for StatusLineConfig {
23 fn default() -> Self {
24 Self {
25 enable: true,
26 errors: true,
27 signature: true,
28 output_type: true,
29 preview: true,
30 }
31 }
32}
33
34impl UpdateFromValue for StatusLineConfig {
35 fn update<'a>(
36 &mut self,
37 value: &'a Value,
38 path: &mut ConfigPath<'a>,
39 errors: &mut ConfigErrors,
40 ) {
41 let Value::Record { val: record, .. } = value else {
42 errors.type_mismatch(path, Type::record(), value);
43 return;
44 };
45
46 for (col, val) in record.iter() {
47 let path = &mut path.push(col);
48 match col.as_str() {
49 "enable" => self.enable.update(val, path, errors),
50 "errors" => self.errors.update(val, path, errors),
51 "signature" => self.signature.update(val, path, errors),
52 "type" => self.output_type.update(val, path, errors),
53 "preview" => self.preview.update(val, path, errors),
54 _ => errors.unknown_option(path, val),
55 }
56 }
57 }
58}