nu_command/env/config/
config_nu.rs1use nu_engine::command_prelude::*;
2use nu_utils::ConfigFileKind;
3
4#[derive(Clone)]
5pub struct ConfigNu;
6
7impl Command for ConfigNu {
8 fn name(&self) -> &str {
9 "config nu"
10 }
11
12 fn signature(&self) -> Signature {
13 Signature::build(self.name())
14 .category(Category::Env)
15 .input_output_types(vec![(Type::Nothing, Type::Any)])
16 .switch(
17 "default",
18 "Print the internal default `config.nu` file instead.",
19 Some('d'),
20 )
21 .switch(
22 "doc",
23 "Print a commented `config.nu` with documentation instead.",
24 Some('s'),
25 )
26 }
27
28 fn description(&self) -> &str {
29 "Edit nu configurations."
30 }
31
32 fn examples(&self) -> Vec<Example<'_>> {
33 vec![
34 Example {
35 description: "open user's config.nu in the default editor",
36 example: "config nu",
37 result: None,
38 },
39 Example {
40 description: "pretty-print a commented `config.nu` that explains common settings",
41 example: "config nu --doc | nu-highlight",
42 result: None,
43 },
44 Example {
45 description: "pretty-print the internal `config.nu` file which is loaded before user's config",
46 example: "config nu --default | nu-highlight",
47 result: None,
48 },
49 ]
50 }
51
52 fn run(
53 &self,
54 engine_state: &EngineState,
55 stack: &mut Stack,
56 call: &Call,
57 _input: PipelineData,
58 ) -> Result<PipelineData, ShellError> {
59 super::config_::handle_call(ConfigFileKind::Config, engine_state, stack, call)
60 }
61}