mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 23:58:06 +02:00
remove extern-wrapped
and export extern-wrapped
(#11000)
follow-up to - https://github.com/nushell/nushell/pull/10716 > **Important** > wait for between 0.87 and 0.88 to land this # Description it's time for removal again 😋 this PR removes `extern-wrapped` and `export extern-wrapped` in favor of `def --wrapped` # User-Facing Changes `extern-wrapped` and `export extern-wrapped` will not be found anymore. # Tests + Formatting # After Submitting
This commit is contained in:
@ -1,66 +0,0 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ExportExternWrapped;
|
||||
|
||||
impl Command for ExportExternWrapped {
|
||||
fn name(&self) -> &str {
|
||||
"export extern-wrapped"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Define an extern with a custom code block and export it from a module."
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("export extern-wrapped")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.required("def_name", SyntaxShape::String, "definition name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("body", SyntaxShape::Block, "wrapper code block")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
_stack: &mut Stack,
|
||||
call: &Call,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
nu_protocol::report_error_new(
|
||||
engine_state,
|
||||
&ShellError::GenericError(
|
||||
"Deprecated command".into(),
|
||||
"`export extern-wrapped` is deprecated and will be removed in 0.88.".into(),
|
||||
Some(call.head),
|
||||
Some("Use `export def --wrapped` instead".into()),
|
||||
vec![],
|
||||
),
|
||||
);
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Export the signature for an external command",
|
||||
example: r#"export extern-wrapped my-echo [...rest] { echo $rest }"#,
|
||||
result: None,
|
||||
}]
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["signature", "module", "declare"]
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ExternWrapped;
|
||||
|
||||
impl Command for ExternWrapped {
|
||||
fn name(&self) -> &str {
|
||||
"extern-wrapped"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Define a signature for an external command with a custom code block."
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("extern-wrapped")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("def_name", SyntaxShape::String, "definition name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("body", SyntaxShape::Block, "wrapper code block")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
_stack: &mut Stack,
|
||||
call: &Call,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
nu_protocol::report_error_new(
|
||||
engine_state,
|
||||
&ShellError::GenericError(
|
||||
"Deprecated command".into(),
|
||||
"`extern-wrapped` is deprecated and will be removed in 0.88.".into(),
|
||||
Some(call.head),
|
||||
Some("Use `def --wrapped` instead".into()),
|
||||
vec![],
|
||||
),
|
||||
);
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Define a custom wrapper for an external command",
|
||||
example: r#"extern-wrapped my-echo [...rest] { echo $rest }; my-echo spam"#,
|
||||
result: Some(Value::test_list(vec![Value::test_string("spam")])),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use super::ExternWrapped;
|
||||
use crate::test_examples;
|
||||
test_examples(ExternWrapped {})
|
||||
}
|
||||
}
|
@ -15,11 +15,9 @@ mod export_const;
|
||||
mod export_def;
|
||||
mod export_def_env;
|
||||
mod export_extern;
|
||||
mod export_extern_wrapped;
|
||||
mod export_module;
|
||||
mod export_use;
|
||||
mod extern_;
|
||||
mod extern_wrapped;
|
||||
mod for_;
|
||||
mod hide;
|
||||
mod hide_env;
|
||||
@ -56,11 +54,9 @@ pub use export_const::ExportConst;
|
||||
pub use export_def::ExportDef;
|
||||
pub use export_def_env::ExportDefEnv;
|
||||
pub use export_extern::ExportExtern;
|
||||
pub use export_extern_wrapped::ExportExternWrapped;
|
||||
pub use export_module::ExportModule;
|
||||
pub use export_use::ExportUse;
|
||||
pub use extern_::Extern;
|
||||
pub use extern_wrapped::ExternWrapped;
|
||||
pub use for_::For;
|
||||
pub use hide::Hide;
|
||||
pub use hide_env::HideEnv;
|
||||
|
@ -33,11 +33,9 @@ pub fn create_default_context() -> EngineState {
|
||||
ExportDef,
|
||||
ExportDefEnv,
|
||||
ExportExtern,
|
||||
ExportExternWrapped,
|
||||
ExportUse,
|
||||
ExportModule,
|
||||
Extern,
|
||||
ExternWrapped,
|
||||
For,
|
||||
Hide,
|
||||
HideEnv,
|
||||
|
Reference in New Issue
Block a user