mirror of
https://github.com/nushell/nushell.git
synced 2024-12-14 03:02:05 +01:00
19 lines
556 B
Rust
19 lines
556 B
Rust
use crate::errors::ShellError;
|
|
use crate::object::{dir_entry_dict, Value};
|
|
use crate::prelude::*;
|
|
|
|
pub fn ls(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|
let cwd = args.env.lock().unwrap().cwd().to_path_buf();
|
|
|
|
let entries = std::fs::read_dir(&cwd).map_err(|e| ShellError::string(format!("{:?}", e)))?;
|
|
|
|
let mut shell_entries = VecDeque::new();
|
|
|
|
for entry in entries {
|
|
let value = Value::Object(dir_entry_dict(&entry?)?);
|
|
shell_entries.push_back(ReturnValue::Value(value))
|
|
}
|
|
|
|
Ok(shell_entries.boxed())
|
|
}
|