2021-09-29 20:25:05 +02:00
|
|
|
use nu_protocol::ast::Call;
|
2021-10-25 18:58:58 +02:00
|
|
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
|
|
|
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
2021-09-29 20:25:05 +02:00
|
|
|
|
2021-10-25 06:01:02 +02:00
|
|
|
#[derive(Clone)]
|
2021-09-29 20:25:05 +02:00
|
|
|
pub struct Use;
|
|
|
|
|
|
|
|
impl Command for Use {
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"use"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"Use definitions from a module"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> nu_protocol::Signature {
|
2021-10-26 23:06:08 +02:00
|
|
|
Signature::build("use").rest("pattern", SyntaxShape::String, "import pattern parts")
|
2021-09-29 20:25:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&self,
|
2021-10-25 08:31:39 +02:00
|
|
|
_engine_state: &EngineState,
|
|
|
|
_stack: &mut Stack,
|
2021-11-06 06:50:33 +01:00
|
|
|
call: &Call,
|
2021-10-25 06:01:02 +02:00
|
|
|
_input: PipelineData,
|
|
|
|
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
2021-11-06 06:50:33 +01:00
|
|
|
Ok(PipelineData::new(call.head))
|
2021-09-29 20:25:05 +02:00
|
|
|
}
|
|
|
|
}
|