mirror of
https://github.com/nushell/nushell.git
synced 2025-03-03 18:01:27 +01:00
30 lines
699 B
Rust
30 lines
699 B
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::errors::ShellError;
|
|
use crate::prelude::*;
|
|
|
|
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 {
|
|
Signature::build("cd").optional("directory", SyntaxType::Path)
|
|
}
|
|
}
|
|
|
|
fn cd(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
|
let shell_manager = args.shell_manager.clone();
|
|
let args = args.evaluate_once(registry)?;
|
|
shell_manager.cd(args)
|
|
}
|