0

How do I customize the help command in JLine 3? The help in my JLine 3 shell sample displays as:

manager> help
  System:
    exit   exit from app/script
    help   command help
  Builtins:
  ShellCommandRegistry:
    create Create some stuff with minimal fuss...
    delete Deletes some stuff with minimal fuss...
    list   List some stuff with minimal fuss...

I'd like to replace the section titles ("System:", "Builtins:", and "ShellCommandRegistry:") with single "Commands:" title like:

manager> help
  Commands:
    exit   exit from app/script
    help   command help
    create Create some stuff with minimal fuss...
    delete Deletes some stuff with minimal fuss...
    list   List some stuff with minimal fuss...

Any ideas how to control this in JLine 3?

Jan Nielsen
  • 10,892
  • 14
  • 65
  • 119

2 Answers2

0

At the moment it is not possible to customize command groupings.

Will be fixed in next JLine version (> 3.15.0):
Added help command options: --nogroups (--groups) and --info.
Default grouping behaviour can be controlled by setting

systemRegistry.setGroupCommandsInHelp(true/false)

.

groovy-repl> help --help
help -  command help
Usage: help [TOPIC...]
  -? --help                      Displays command help
     --nogroups                  Commands are not grouped by registeries
  -i --info                      List commands with a short command infos
groovy-repl> 
mattirn
  • 26
  • 4
0

Using jline 3.20.0:

I wrote my own Registry and registered the other into this one, like this:

MyAppCommands myAppCommands = new MyAppCommands(parser, terminal, workDir, null);
myAppCommands.setCommandRegistries(builtins, picocliCommands);
myAppCommands.register("help", myAppCommands);

where MyAppCommands extends SystemRegistryImpl. Then the help command shows only the class-name "MyAppCommands:"

Therefore if you name your registry class "Commands" you'll get your desired result!

Mayra Delgado
  • 531
  • 4
  • 17