nushell/crates/nu-command/src/commands/pwd.rs

53 lines
1.1 KiB
Rust
Raw Normal View History

2019-09-07 17:49:15 +02:00
use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
2019-11-30 01:21:05 +01:00
use nu_protocol::Signature;
2019-09-07 17:49:15 +02:00
pub struct Pwd;
2019-09-07 17:49:15 +02:00
impl WholeStreamCommand for Pwd {
2019-09-07 17:49:15 +02:00
fn name(&self) -> &str {
"pwd"
}
fn signature(&self) -> Signature {
Signature::build("pwd")
}
fn usage(&self) -> &str {
"Output the current working directory."
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
pwd(args)
2019-09-07 17:49:15 +02:00
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Print the current working directory",
example: "pwd",
result: None,
}]
}
2019-09-07 17:49:15 +02:00
}
pub fn pwd(args: CommandArgs) -> Result<ActionStream, ShellError> {
let shell_manager = args.shell_manager.clone();
let args = args.evaluate_once()?;
shell_manager.pwd(args)
2019-09-07 17:49:15 +02:00
}
#[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;
2021-02-12 11:13:14 +01:00
test_examples(Pwd {})
}
}