From 1662e61ecb9332a1c03825ec5bc677d15c8e5c89 Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Thu, 19 Oct 2023 07:50:16 +0200 Subject: [PATCH] deprecate `def-env` and `export def-env` (#10715) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit follow-up to - https://github.com/nushell/nushell/pull/10566 # Description this PR deprecates the use of `def-env` and `export def-env` these two core commands will be removed in 0.88 # User-Facing Changes using `def-env` will give a warning ```nushell > def-env foo [] { print "foo" }; foo Error: × Deprecated command ╭─[entry #1:1:1] 1 │ def-env foo [] { print "foo" }; foo · ───┬─── · ╰── `def-env` is deprecated and will be removed in 0.88. ╰──── help: Use `def --env` instead foo ``` # Tests + Formatting # After Submitting --- crates/nu-cmd-lang/src/core_commands/def_env.rs | 14 ++++++++++++-- .../src/core_commands/export_def_env.rs | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/nu-cmd-lang/src/core_commands/def_env.rs b/crates/nu-cmd-lang/src/core_commands/def_env.rs index 10c2763897..4d967d7b6d 100644 --- a/crates/nu-cmd-lang/src/core_commands/def_env.rs +++ b/crates/nu-cmd-lang/src/core_commands/def_env.rs @@ -37,11 +37,21 @@ impl Command for DefEnv { fn run( &self, - _engine_state: &EngineState, + engine_state: &EngineState, _stack: &mut Stack, - _call: &Call, + call: &Call, _input: PipelineData, ) -> Result { + nu_protocol::report_error_new( + engine_state, + &ShellError::GenericError( + "Deprecated command".into(), + "`def-env` is deprecated and will be removed in 0.88.".into(), + Some(call.head), + Some("Use `def --env` instead".into()), + vec![], + ), + ); Ok(PipelineData::empty()) } diff --git a/crates/nu-cmd-lang/src/core_commands/export_def_env.rs b/crates/nu-cmd-lang/src/core_commands/export_def_env.rs index 54c6668f3c..ce2aed5ca8 100644 --- a/crates/nu-cmd-lang/src/core_commands/export_def_env.rs +++ b/crates/nu-cmd-lang/src/core_commands/export_def_env.rs @@ -62,11 +62,21 @@ export def-env cd_with_fallback [arg = ""] { fn run( &self, - _engine_state: &EngineState, + engine_state: &EngineState, _stack: &mut Stack, - _call: &Call, + call: &Call, _input: PipelineData, ) -> Result { + nu_protocol::report_error_new( + engine_state, + &ShellError::GenericError( + "Deprecated command".into(), + "`export def-env` is deprecated and will be removed in 0.88.".into(), + Some(call.head), + Some("Use `export def --env` instead".into()), + vec![], + ), + ); Ok(PipelineData::empty()) }