2019-08-19 07:16:39 +02:00
|
|
|
use crate::commands::WholeStreamCommand;
|
2019-05-11 09:00:33 +02:00
|
|
|
use crate::errors::ShellError;
|
2019-05-13 19:30:51 +02:00
|
|
|
use crate::prelude::*;
|
2019-08-09 06:51:21 +02:00
|
|
|
|
2019-08-19 07:16:39 +02:00
|
|
|
pub struct CD;
|
|
|
|
|
|
|
|
impl WholeStreamCommand for CD {
|
2019-08-30 00:52:32 +02:00
|
|
|
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",
|
|
|
|
)
|
2019-08-30 00:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"Change to a new path."
|
|
|
|
}
|
|
|
|
|
2019-08-19 07:16:39 +02:00
|
|
|
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
|
|
|
}
|