0

如何自定义 JLine 3 中的帮助命令?我的JLine 3 shell 示例中的帮助显示为:

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...

我想用单个“Commands:”标题替换部分标题(“System:”,“Builtins:”和“ShellCommandRegistry:”),例如:

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...

任何想法如何在 JLine 3 中控制它?

4

2 回答 2

0

目前无法自定义命令分组。

将在下一个 JLine 版本 (> 3.15.0) 中修复:
添加了帮助命令选项:--nogroups (--groups) 和--info。
默认分组行为可以通过设置来控制

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> 
于 2020-06-17T15:38:10.667 回答
0

使用 jline 3.20.0:

我编写了自己的注册表并将另一个注册到这个注册表中,如下所示:

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

其中 MyAppCommands 扩展了 SystemRegistryImpl。然后帮助命令只显示类名“MyAppCommands:”

因此,如果您将注册表类命名为“Commands”,您将获得所需的结果!

于 2021-11-17T11:14:25.650 回答