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: ®istry::CommandRegistry,
|
|
|
|
_shell_manager: &ShellManager,
|
|
|
|
_input: Tagged<Value>,
|
2019-08-14 19:02:39 +02:00
|
|
|
) -> Result<VecDeque<ReturnValue>, ShellError> {
|
|
|
|
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
|
|
|
}
|