mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:55:07 +02:00
Rework help
generation internals (#13531)
Reworking some of the sprawling code we use to generate the `help cmd` or `cmd --help` output. This touches mainly the rendering and not the gathering of the necessary data (see open bugs under [label:help-system](https://github.com/nushell/nushell/issues?q=sort%3Aupdated-desc+is%3Aopen+label%3Ahelp-system)) Fixes #9076 Fixes the syntax shape output on flags to be consistent. ## Example ```nushell def test [ positional: int, documented: float, # this has documentation default = 50, optional?, --a = "bla", --bla (-b) = "bla", # named with default ] {} ``` ### before  ### after 
This commit is contained in:
committed by
GitHub
parent
1c37f4b958
commit
9172b22985
@ -9,7 +9,7 @@ use std::{
|
||||
thread,
|
||||
};
|
||||
|
||||
use nu_engine::documentation::get_flags_section;
|
||||
use nu_engine::documentation::{get_flags_section, HelpStyle};
|
||||
use nu_plugin_core::{
|
||||
ClientCommunicationIo, CommunicationMode, InterfaceManager, PluginEncoder, PluginRead,
|
||||
PluginWrite,
|
||||
@ -657,6 +657,7 @@ fn print_help(plugin: &impl Plugin, encoder: impl PluginEncoder) {
|
||||
println!("Encoder: {}", encoder.name());
|
||||
|
||||
let mut help = String::new();
|
||||
let help_style = HelpStyle::default();
|
||||
|
||||
plugin.commands().into_iter().for_each(|command| {
|
||||
let signature = command.signature();
|
||||
@ -670,7 +671,7 @@ fn print_help(plugin: &impl Plugin, encoder: impl PluginEncoder) {
|
||||
}
|
||||
})
|
||||
.and_then(|_| {
|
||||
let flags = get_flags_section(None, None, &signature, |v| format!("{:#?}", v));
|
||||
let flags = get_flags_section(&signature, &help_style, |v| format!("{:#?}", v));
|
||||
write!(help, "{flags}")
|
||||
})
|
||||
.and_then(|_| writeln!(help, "\nParameters:"))
|
||||
|
Reference in New Issue
Block a user