nushell/src/commands/cd.rs

39 lines
885 B
Rust
Raw Normal View History

use crate::commands::WholeStreamCommand;
use crate::prelude::*;
use nu_errors::ShellError;
2019-11-30 01:21:05 +01:00
use nu_protocol::{Signature, SyntaxShape};
2019-08-09 06:51:21 +02:00
pub struct CD;
impl WholeStreamCommand for CD {
fn name(&self) -> &str {
"cd"
}
fn signature(&self) -> Signature {
2019-10-28 06:15:35 +01:00
Signature::build("cd").optional(
"directory",
SyntaxShape::Path,
"the directory to change to",
)
}
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
}