mirror of
https://github.com/nushell/nushell.git
synced 2025-04-11 23:08:20 +02:00
Also migrate mv, rm and commands like that to taking a SyntaxType::Pattern instead of a SyntaxType::Path for their first argument.
34 lines
769 B
Rust
34 lines
769 B
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::errors::ShellError;
|
|
use crate::prelude::*;
|
|
|
|
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> {
|
|
let shell_manager = args.shell_manager.clone();
|
|
let args = args.evaluate_once(registry)?;
|
|
shell_manager.cd(args)
|
|
}
|