nushell/src/commands/enter.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

2019-08-07 19:49:11 +02:00
use crate::commands::command::CommandAction;
2019-08-15 07:02:02 +02:00
use crate::commands::PerItemCommand;
2019-08-07 19:49:11 +02:00
use crate::errors::ShellError;
2019-08-14 19:02:39 +02:00
use crate::parser::registry;
2019-08-07 19:49:11 +02:00
use crate::prelude::*;
2019-08-14 19:02:39 +02:00
pub struct Enter;
2019-08-09 06:51:21 +02:00
2019-08-14 19:02:39 +02:00
impl PerItemCommand for Enter {
fn name(&self) -> &str {
"enter"
2019-08-07 19:49:11 +02:00
}
2019-08-14 19:02:39 +02:00
fn signature(&self) -> registry::Signature {
Signature::build("enter").required("location", SyntaxType::Block)
}
fn run(
&self,
2019-08-15 07:02:02 +02:00
call_info: &CallInfo,
_registry: &registry::CommandRegistry,
2019-08-29 05:53:45 +02:00
_raw_args: &RawCommandArgs,
2019-08-15 07:02:02 +02:00
_input: Tagged<Value>,
2019-08-24 21:36:19 +02:00
) -> Result<OutputStream, ShellError> {
2019-08-14 19:02:39 +02:00
match call_info.args.expect_nth(0)? {
Tagged {
item: Value::Primitive(Primitive::String(location)),
..
} => Ok(vec![Ok(ReturnSuccess::Action(CommandAction::EnterShell(
location.to_string(),
)))]
.into()),
x => Ok(
vec![Ok(ReturnSuccess::Action(CommandAction::EnterValueShell(
x.clone(),
)))]
.into(),
),
}
}
2019-08-07 19:49:11 +02:00
}