nushell/src/commands/cd.rs

34 lines
769 B
Rust
Raw Normal View History

use crate::commands::WholeStreamCommand;
2019-05-11 09:00:33 +02:00
use crate::errors::ShellError;
use crate::prelude::*;
2019-08-09 06:51:21 +02:00
pub struct CD;
impl WholeStreamCommand for CD {
fn name(&self) -> &str {
"cd"
}
fn signature(&self) -> Signature {
Signature::build("cd").optional("directory", SyntaxShape::Path)
}
fn usage(&self) -> &str {
"Change to a new path."
}
fn run(
&self,
args: CommandArgs,
registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> {
cd(args, registry)
}
}
fn cd(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
2019-08-09 21:42:23 +02:00
let shell_manager = args.shell_manager.clone();
let args = args.evaluate_once(registry)?;
shell_manager.cd(args)
2019-05-11 09:00:33 +02:00
}