endpoint 2.0 dysnomia.ptr.pet
0
fork

Configure Feed

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

at main 46 lines 1.2 kB view raw
1use crate::globals::print_to_console; 2use nu_engine::CallExt; 3use nu_protocol::{ 4 Category, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, 5 engine::{Command, EngineState, Stack}, 6}; 7 8#[derive(Clone)] 9pub struct Print; 10 11impl Command for Print { 12 fn name(&self) -> &str { 13 "print" 14 } 15 16 fn signature(&self) -> Signature { 17 Signature::build("print") 18 .rest("rest", SyntaxShape::Any, "values to print") 19 .input_output_type(Type::Nothing, Type::Nothing) 20 .category(Category::Strings) 21 } 22 23 fn description(&self) -> &str { 24 "print values to the console." 25 } 26 27 fn run( 28 &self, 29 engine_state: &EngineState, 30 stack: &mut Stack, 31 call: &nu_protocol::engine::Call, 32 _input: PipelineData, 33 ) -> Result<PipelineData, ShellError> { 34 let rest: Vec<Value> = call.rest(engine_state, stack, 0)?; 35 36 let mut parts = Vec::new(); 37 for value in rest { 38 let s = value.to_expanded_string(" ", &engine_state.config); 39 parts.push(s); 40 } 41 let output = parts.join(" "); 42 print_to_console(&output, true); 43 44 Ok(PipelineData::Empty) 45 } 46}