mirror of
https://github.com/nushell/nushell.git
synced 2025-07-05 17:10:45 +02:00
add signature information when get help on one command (#7079)
* add signature information when help on one command * tell user that one command support operated on cell paths Also, make type output to be more friendly, like `record<>` should just be `record` And the same to `table<>`, which should be `table` * simplify code * don't show signatures for parser keyword * update comment * output arg syntax shape as type, so it's the same as describe command * fix string when no positional args * update signature body * update * add help signature test * fix arg output format for composed data type like list or record * fix clippy * add comment
This commit is contained in:
@ -10,6 +10,7 @@ pub fn get_full_help(
|
||||
examples: &[Example],
|
||||
engine_state: &EngineState,
|
||||
stack: &mut Stack,
|
||||
is_parser_keyword: bool,
|
||||
) -> String {
|
||||
let config = engine_state.get_config();
|
||||
let doc_config = DocumentationConfig {
|
||||
@ -17,7 +18,14 @@ pub fn get_full_help(
|
||||
no_color: !config.use_ansi_coloring,
|
||||
brief: false,
|
||||
};
|
||||
get_documentation(sig, examples, engine_state, stack, &doc_config)
|
||||
get_documentation(
|
||||
sig,
|
||||
examples,
|
||||
engine_state,
|
||||
stack,
|
||||
&doc_config,
|
||||
is_parser_keyword,
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -34,6 +42,7 @@ fn get_documentation(
|
||||
engine_state: &EngineState,
|
||||
stack: &mut Stack,
|
||||
config: &DocumentationConfig,
|
||||
is_parser_keyword: bool,
|
||||
) -> String {
|
||||
// Create ansi colors
|
||||
const G: &str = "\x1b[32m"; // green
|
||||
@ -89,6 +98,18 @@ fn get_documentation(
|
||||
long_desc.push_str(&get_flags_section(sig))
|
||||
}
|
||||
|
||||
if !is_parser_keyword && !sig.input_output_types.is_empty() {
|
||||
if sig.operates_on_cell_paths() {
|
||||
let _ = writeln!(
|
||||
long_desc,
|
||||
"\n{}Signatures(Cell paths are supported){}:\n{}",
|
||||
G, RESET, sig
|
||||
);
|
||||
} else {
|
||||
let _ = writeln!(long_desc, "\n{}Signatures{}:\n{}", G, RESET, sig);
|
||||
}
|
||||
}
|
||||
|
||||
if !sig.required_positional.is_empty()
|
||||
|| !sig.optional_positional.is_empty()
|
||||
|| sig.rest_positional.is_some()
|
||||
|
Reference in New Issue
Block a user