-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
let_env.rs
43 lines (38 loc) · 1.26 KB
/
let_env.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct LetEnv;
impl Command for LetEnv {
fn name(&self) -> &str {
"let-env"
}
fn signature(&self) -> Signature {
Signature::build(self.name())
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
.allow_variants_without_examples(true)
.optional("var_name", SyntaxShape::String, "variable name")
.optional(
"initial_value",
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
"equals sign followed by value",
)
.category(Category::Deprecated)
}
fn usage(&self) -> &str {
"`let-env FOO = ...` is deprecated, use `$env.FOO = ...` instead."
}
fn run(
&self,
_: &EngineState,
_: &mut Stack,
call: &Call,
_: PipelineData,
) -> Result<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"$env.<environment variable> = ...".to_owned(),
call.head,
))
}
}