nu_command/path/
path_.rs

1use nu_engine::{command_prelude::*, get_full_help};
2
3#[derive(Clone)]
4pub struct Path;
5
6impl Command for Path {
7    fn name(&self) -> &str {
8        "path"
9    }
10
11    fn signature(&self) -> Signature {
12        Signature::build("path")
13            .input_output_types(vec![(Type::Nothing, Type::String)])
14            .category(Category::Path)
15    }
16
17    fn description(&self) -> &str {
18        "Explore and manipulate paths."
19    }
20
21    fn extra_description(&self) -> &str {
22        r#"You must use one of the following subcommands. Using this command as-is will only produce this help message.
23
24There are three ways to represent a path:
25
26* As a path literal, e.g., '/home/viking/spam.txt'
27* As a structured path: a table with 'parent', 'stem', and 'extension' (and
28* 'prefix' on Windows) columns. This format is produced by the 'path parse'
29  subcommand.
30* As a list of path parts, e.g., '[ / home viking spam.txt ]'. Splitting into
31  parts is done by the `path split` command.
32
33All subcommands accept all three variants as an input. Furthermore, the 'path
34join' subcommand can be used to join the structured path or path parts back into
35the path literal."#
36    }
37
38    fn run(
39        &self,
40        engine_state: &EngineState,
41        stack: &mut Stack,
42        call: &Call,
43        _input: PipelineData,
44    ) -> Result<PipelineData, ShellError> {
45        Ok(Value::string(get_full_help(self, engine_state, stack), call.head).into_pipeline_data())
46    }
47}