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