nushell/src/commands/ls.rs

34 lines
792 B
Rust
Raw Normal View History

use crate::commands::WholeStreamCommand;
2019-05-10 18:59:12 +02:00
use crate::errors::ShellError;
use crate::prelude::*;
2019-05-10 18:59:12 +02:00
pub struct LS;
impl WholeStreamCommand for LS {
fn name(&self) -> &str {
"ls"
}
fn signature(&self) -> Signature {
Signature::build("ls").optional("path", SyntaxType::Pattern)
}
fn usage(&self) -> &str {
"View the contents of the current or given path."
}
fn run(
&self,
args: CommandArgs,
registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> {
ls(args, registry)
}
}
fn ls(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let shell_manager = args.shell_manager.clone();
let args = args.evaluate_once(registry)?;
shell_manager.ls(args)
2019-05-10 18:59:12 +02:00
}