endpoint 2.0 dysnomia.ptr.pet
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 40 lines 1.0 kB view raw
1use crate::globals::get_pwd; 2use nu_protocol::Type; 3use nu_protocol::engine::Call; 4use nu_protocol::{ 5 Category, IntoPipelineData, PipelineData, ShellError, Signature, Value, 6 engine::{Command, EngineState, Stack}, 7}; 8 9#[derive(Clone)] 10pub struct Pwd; 11 12impl Command for Pwd { 13 fn name(&self) -> &str { 14 "pwd" 15 } 16 17 fn signature(&self) -> Signature { 18 Signature::build("pwd") 19 .input_output_type(Type::Nothing, Type::String) 20 .category(Category::FileSystem) 21 } 22 23 fn description(&self) -> &str { 24 "print the current working directory in the virtual filesystem." 25 } 26 27 fn run( 28 &self, 29 _engine_state: &EngineState, 30 _stack: &mut Stack, 31 call: &Call, 32 _input: PipelineData, 33 ) -> Result<PipelineData, ShellError> { 34 let mut pwd = get_pwd().as_str().to_string(); 35 if pwd.is_empty() { 36 pwd.push('/'); 37 } 38 Ok(Value::string(pwd, call.head).into_pipeline_data()) 39 } 40}