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 {
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
args: CommandArgs,
|
|
|
|
registry: &CommandRegistry,
|
|
|
|
) -> Result<OutputStream, ShellError> {
|
|
|
|
cd(args, registry)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"cd"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
2019-08-20 05:11:29 +02:00
|
|
|
Signature::build("cd").optional("directory", SyntaxType::Path)
|
2019-08-19 07:16:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|