nu_cmd_lang/core_commands/attr/
search_terms.rs1use nu_engine::command_prelude::*;
2
3#[derive(Clone)]
4pub struct AttrSearchTerms;
5
6impl Command for AttrSearchTerms {
7 fn name(&self) -> &str {
8 "attr search-terms"
9 }
10
11 fn signature(&self) -> Signature {
12 Signature::build("attr search-terms")
13 .input_output_type(Type::Nothing, Type::list(Type::String))
14 .allow_variants_without_examples(true)
15 .rest("terms", SyntaxShape::String, "Search terms.")
16 .category(Category::Core)
17 }
18
19 fn description(&self) -> &str {
20 "Attribute for adding search terms to custom commands."
21 }
22
23 fn run(
24 &self,
25 engine_state: &EngineState,
26 stack: &mut Stack,
27 call: &Call,
28 _input: PipelineData,
29 ) -> Result<PipelineData, ShellError> {
30 let args = call.rest(engine_state, stack, 0)?;
31 Ok(Value::list(args, call.head).into_pipeline_data())
32 }
33
34 fn run_const(
35 &self,
36 working_set: &StateWorkingSet,
37 call: &Call,
38 _input: PipelineData,
39 ) -> Result<PipelineData, ShellError> {
40 let args = call.rest_const(working_set, 0)?;
41 Ok(Value::list(args, call.head).into_pipeline_data())
42 }
43
44 fn is_const(&self) -> bool {
45 true
46 }
47
48 fn examples(&self) -> Vec<Example<'_>> {
49 vec![Example {
50 description: "Add search terms to a custom command",
51 example: r###"# Double numbers
52 @search-terms multiply times
53 def double []: [number -> number] { $in * 2 }"###,
54 result: None,
55 }]
56 }
57}