mirror of
https://github.com/nushell/nushell.git
synced 2025-04-29 15:44:28 +02:00
# Description in this PR i propose to remove the following old deprecated commands - `hash base64` -> `encode base64` - `math eval` -> `math <sub>` - `str to-datetime` -> `into datetime` - `str to-decimal` -> `into decimal` - `str find-replace` -> `str replace` - `str to-int` -> `into int` - `keep` -> `take` - `match` -> `find` - `nth` -> `select` - `pivot` -> `transpose` - `unalias` -> `hide` - `all?` -> `all` - `any?` -> `any` - `empty?` -> `is-empty` - `build-string` -> `str join` / string concatenation with `+` - `str lpad` -> `fill` - `str rpad` -> `fill` - `str collect` -> `str join` - `old-alias` -> `alias` so old i do not remember them at all 😮 i left the following four commands because they have been moved much more recently i think! - `fetch` -> `http get` - `post` -> `http post` - `benchmark` -> `timeit` - `let-env` - `date format` -> `format date` # User-Facing Changes # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - ⚫ `toolkit test` - ⚫ `toolkit test stdlib` # After Submitting
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
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,
|
|
))
|
|
}
|
|
}
|