Help Options
Spring Shell 有一个内置 help
命令,但并非所有人喜欢从它那里获取命令帮助,因为你总是需要用目标命令的参数来调用它。在许多 cli 框架中,对于每个具有 —help 和 -h 选项的命令,打印命令帮助很常见。
Spring Shell has a build-in help
command but not all favour getting command help
from it as you always need to call it with arguments for target command. It’s
common in many cli frameworks for every command having options —help and -h
to print out command help.
默认功能是每个命令都将被修改为具有 —help 和 -h 选项,如果它们存在于给定命令中,将自动将命令执行短路到现有的 help
命令,无论键入了什么其他命令行选项。
Default functionality is that every command will get modified to have options
—help and -h, which if present in a given command will automatically
short circuit command execution into a existing help
command regardless
what other command-line options is typed.
以下示例展示了其默认设置。
Below example shows its default settings.
Unresolved include directive in modules/ROOT/pages/commands/helpoptions.adoc - include::../../test/java/org/springframework/shell/docs/CommandRegistrationHelpOptionsSnippets.java[]
可以通过配置选项更改默认行为。
It is possible to change default behaviour via configuration options.
spring:
shell:
help:
enabled: true
long-names: help
short-names: h
command: help
通过编程或注解定义的命令将自动添加帮助选项。使用注解模型你只能全局关闭,而编程模型给出了按命令修改设置的选项。 |
Commands defined programmationally or via annotations will automatically add help options. With annotation model you can only turn things off globally, programmatic model gives option to modify settings per command. |