nu_command/removed/
let_env.rs

1use nu_engine::command_prelude::*;
2
3#[derive(Clone)]
4pub struct LetEnv;
5
6impl Command for LetEnv {
7    fn name(&self) -> &str {
8        "let-env"
9    }
10
11    fn signature(&self) -> Signature {
12        Signature::build(self.name())
13            .input_output_types(vec![(Type::Nothing, Type::Nothing)])
14            .allow_variants_without_examples(true)
15            .optional("var_name", SyntaxShape::String, "Variable name.")
16            .optional(
17                "initial_value",
18                SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
19                "Equals sign followed by value.",
20            )
21            .category(Category::Removed)
22    }
23
24    fn description(&self) -> &str {
25        "`let-env FOO = ...` has been removed, use `$env.FOO = ...` instead."
26    }
27
28    fn run(
29        &self,
30        _: &EngineState,
31        _: &mut Stack,
32        call: &Call,
33        _: PipelineData,
34    ) -> Result<PipelineData, ShellError> {
35        Err(nu_protocol::ShellError::RemovedCommand {
36            removed: self.name().to_string(),
37            replacement: "$env.<environment variable> = ...".to_owned(),
38            span: call.head,
39        })
40    }
41}