nushell/crates/nu-command/src/commands/pwd.rs
Jonathan Turner 073e5727c6
Switch to "engine-p" (#3270)
* WIP

* WIP

* first builds

* Tests pass
2021-04-06 11:19:43 -05:00

53 lines
1.1 KiB
Rust

use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::Signature;
pub struct Pwd;
impl WholeStreamCommand for Pwd {
fn name(&self) -> &str {
"pwd"
}
fn signature(&self) -> Signature {
Signature::build("pwd")
}
fn usage(&self) -> &str {
"Output the current working directory."
}
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
pwd(args)
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Print the current working directory",
example: "pwd",
result: None,
}]
}
}
pub fn pwd(args: CommandArgs) -> Result<OutputStream, ShellError> {
let shell_manager = args.shell_manager.clone();
let args = args.evaluate_once()?;
shell_manager.pwd(args)
}
#[cfg(test)]
mod tests {
use super::Pwd;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Pwd {})
}
}