Add a note to --help that global options are described by sq --help.

- To avoid overwhelming users, we don't describe global options in a
    subcommand's help output.

  - Add a short section that tells the user that there are global
    options, and that they can learn about them from the top-level's
    help output.

  - See #202.
This commit is contained in:
Neal H. Walfield 2024-02-21 12:12:53 +01:00
parent 0382001a65
commit 340751a587
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3

View File

@ -145,12 +145,26 @@ pub fn build(globals_hidden: bool) -> Command {
// Change the globals to be hidden.
if globals_hidden {
command = command.mut_args(|mut a| {
if a.is_global_set() {
a = a.hide(globals_hidden);
fn add_after_help(command: &mut Command) {
*command = command.clone()
.after_long_help(format!("\
{}:\n See 'sq --help' for a description of the global options.",
GLOBAL_OPTIONS_HEADER));
for sc in command.get_subcommands_mut() {
add_after_help(sc);
}
a
});
}
command = command
.mut_args(|mut a| {
if a.is_global_set() {
a = a.hide(globals_hidden);
}
a
});
add_after_help(&mut command);
};
command