mirror of
https://github.com/nushell/nushell.git
synced 2025-04-15 16:58:19 +02:00
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use crate::commands::command::CommandAction;
|
|
use crate::commands::PerItemCommand;
|
|
use crate::errors::ShellError;
|
|
use crate::parser::registry;
|
|
use crate::prelude::*;
|
|
|
|
pub struct Enter;
|
|
|
|
impl PerItemCommand for Enter {
|
|
fn name(&self) -> &str {
|
|
"enter"
|
|
}
|
|
|
|
fn signature(&self) -> registry::Signature {
|
|
Signature::build("enter").required("location", SyntaxType::Block)
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
call_info: &CallInfo,
|
|
_registry: ®istry::CommandRegistry,
|
|
_shell_manager: &ShellManager,
|
|
_input: Tagged<Value>,
|
|
) -> 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(),
|
|
),
|
|
}
|
|
}
|
|
}
|