Help
运行外壳应用程序通常意味着用户处于受图形限制的环境中。此外,虽然我们在移动电话时代几乎始终处于连接状态,但并非始终都能访问 Web 浏览器或任何其他富 UI 应用程序(例如 PDF 查看器)。这就是外壳命令正确进行自我记录非常重要的原因,此时可使用 help
命令。
Running a shell application often implies that the user is in a graphically limited
environment. Also, while we are nearly always connected in the era of mobile phones,
accessing a web browser or any other rich UI application (such as a PDF viewer) may not always
be possible. This is why it is important that the shell commands are correctly self-documented, and this is where the help
command comes in.
输入 help
+ ENTER
会列出 shell 已知的(包括 unavailable 命令)所有命令,以及它们的作用的简短描述,如下所示:
Typing help
+ ENTER
lists all the commands known to the shell (including unavailable commands)
and a short description of what they do, similar to the following:
my-shell:>help
AVAILABLE COMMANDS
Built-In Commands
exit: Exit the shell.
help: Display help about available commands
stacktrace: Display the full stacktrace of the last error.
clear: Clear the shell screen.
quit: Exit the shell.
history: Display or save the history of previously run commands
completion bash: Generate bash completion script
version: Show version info
script: Read and execute commands from a file.
键入 help <command>
会显示有关命令的更详细信息,包括可用参数、其类型、它们是否为必填项以及其他详细信息。
Typing help <command>
shows more detailed information about a command, including the available parameters, their
type, whether they are mandatory or not, and other details.
以下列表显示了应用于其自身的 help
命令:
The following listing shows the help
command applied to itself:
my-shell:>help help
NAME
help - Display help about available commands
SYNOPSIS
help --command String
OPTIONS
--command or -C String
The command to obtain help for.
[Optional]
帮助是模板化的,并且可以在需要时进行定制。设置位于 spring.shell.command.help
,可以在其中使用 enabled
禁用命令,使用 grouping-mode
和 group
或 flat
通过扁平化结构隐藏组,使用 command-template
定义用于命令帮助输出的模板,使用 commands-template
定义命令列表的输出。
Help is templated and can be customized if needed. Settings are under spring.shell.command.help
where you can use
enabled
to disable command, grouping-mode
taking group
or flat
if you want to hide groups by flattening
a structure, command-template
to define your template for output of a command help, commands-template
to define
output of a command list.
如果设置了 spring.shell.command.help.grouping-mode=flat
,则帮助会显示:
If spring.shell.command.help.grouping-mode=flat
is set, then help would show:
my-shell:>help help
AVAILABLE COMMANDS
exit: Exit the shell.
help: Display help about available commands
stacktrace: Display the full stacktrace of the last error.
clear: Clear the shell screen.
quit: Exit the shell.
history: Display or save the history of previously run commands
completion bash: Generate bash completion script
version: Show version info
script: Read and execute commands from a file.
help
和 help <commmand>
的输出都使用默认实现进行了模板化,该实现可以更改。
Output from help
and help <commmand>
are both templated with a default implementation
which can be changed.
选项 spring.shell.command.help.commands-template
默认为 classpath:template/help-commands-default.stg
,并被传递 GroupsInfoModel
为模型。
Option spring.shell.command.help.commands-template
defaults to
classpath:template/help-commands-default.stg
and is passed GroupsInfoModel
as a model.
选项 spring.shell.command.help.command-template
默认为 classpath:template/help-command-default.stg
,并被传递 CommandInfoModel
为模型。
Option spring.shell.command.help.command-template
defaults to
classpath:template/help-command-default.stg
and is passed CommandInfoModel
as a model.
Key | Description |
---|---|
|
|
|
The commands variables (see GroupCommandInfoModel Variables). |
|
The commands variables (see CommandInfoModel Variables). |
|
|
Key | Description |
---|---|
|
The name of a group, if set. Otherwise, empty. |
|
The commands, if set. Otherwise, empty. Type is a multi value, see CommandInfoModel Variables. |
Key | Description |
---|---|
|
The name of a command, if set. Otherwise, null. Type is string and contains full command. |
|
The names of a command, if set. Otherwise, null. Type is multi value essentially |
|
The possible aliases, if set. Type is multi value with strings. |
|
The description of a command, if set. Otherwise, null. |
|
The parameters variables, if set. Otherwise empty. Type is a multi value, see CommandParameterInfoModel Variables. |
|
The availability variables (see CommandAvailabilityInfoModel Variables). |
Key | Description |
---|---|
|
The type of a parameter if set. Otherwise, null. |
|
The arguments, if set. Otherwise, null. Type is multi value with strings. |
|
|
|
The description of a parameter, if set. Otherwise, null. |
|
The default value of a parameter, if set. Otherwise, null. |
|
|
Key | Description |
---|---|
|
|
|
The reason if not available if set. Otherwise, null. |