mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:35:56 +02:00
Merge branch 'main' into source-command
This commit is contained in:
35
crates/nu-command/src/core_commands/export_def.rs
Normal file
35
crates/nu-command/src/core_commands/export_def.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EvaluationContext};
|
||||
use nu_protocol::{Signature, SyntaxShape, Value};
|
||||
|
||||
pub struct ExportDef;
|
||||
|
||||
impl Command for ExportDef {
|
||||
fn name(&self) -> &str {
|
||||
"export def"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Define a custom command and export it from a module"
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("export def")
|
||||
.required("target", SyntaxShape::String, "definition name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required(
|
||||
"block",
|
||||
SyntaxShape::Block(Some(vec![])),
|
||||
"body of the definition",
|
||||
)
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_context: &EvaluationContext,
|
||||
call: &Call,
|
||||
_input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
Ok(Value::Nothing { span: call.head })
|
||||
}
|
||||
}
|
28
crates/nu-command/src/core_commands/hide.rs
Normal file
28
crates/nu-command/src/core_commands/hide.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EvaluationContext};
|
||||
use nu_protocol::{Signature, SyntaxShape, Value};
|
||||
|
||||
pub struct Hide;
|
||||
|
||||
impl Command for Hide {
|
||||
fn name(&self) -> &str {
|
||||
"hide"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Hide definitions in the current scope"
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("hide").required("pattern", SyntaxShape::String, "import pattern")
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_context: &EvaluationContext,
|
||||
call: &Call,
|
||||
_input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
Ok(Value::Nothing { span: call.head })
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
mod alias;
|
||||
mod def;
|
||||
mod do_;
|
||||
mod export_def;
|
||||
mod help;
|
||||
mod hide;
|
||||
mod if_;
|
||||
mod let_;
|
||||
mod module;
|
||||
@ -11,7 +13,9 @@ mod use_;
|
||||
pub use alias::Alias;
|
||||
pub use def::Def;
|
||||
pub use do_::Do;
|
||||
pub use export_def::ExportDef;
|
||||
pub use help::Help;
|
||||
pub use hide::Hide;
|
||||
pub use if_::If;
|
||||
pub use let_::Let;
|
||||
pub use module::Module;
|
||||
|
@ -14,7 +14,7 @@ impl Command for Use {
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("use").required("module_name", SyntaxShape::String, "module name")
|
||||
Signature::build("use").required("pattern", SyntaxShape::String, "import pattern")
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
Reference in New Issue
Block a user