此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Shell 3.3.3spring-doc.cadn.net.cn

帮助

运行 shell 应用程序通常意味着用户处于图形受限的 环境。此外,虽然在手机时代我们几乎总是保持连接, 访问 Web 浏览器或任何其他富 UI 应用程序(如 PDF 查看器)可能并不总是 是可能的。这就是为什么 shell 命令必须正确地自记录很重要的原因,这就是help命令进来。spring-doc.cadn.net.cn

打字help + ENTER列出 shell 已知的所有命令(包括不可用的命令) 以及他们工作的简短描述,类似于以下内容:spring-doc.cadn.net.cn

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>显示有关命令的更多详细信息,包括可用参数、其 类型、是否为必填项以及其他详细信息。spring-doc.cadn.net.cn

下面的清单显示了help命令应用于自身:spring-doc.cadn.net.cn

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-modegroupflat如果要通过拼合来隐藏组 a 结构,command-template要定义命令帮助输出的模板,commands-template定义 命令列表的输出。spring-doc.cadn.net.cn

如果spring.shell.command.help.grouping-mode=flat设置,则 help 将显示:spring-doc.cadn.net.cn

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.

输出helphelp <commmand>都使用默认实现进行模板化 可以更改。spring-doc.cadn.net.cn

选择spring.shell.command.help.commands-template默认为classpath:template/help-commands-default.stg并传递GroupsInfoModel作为模型。spring-doc.cadn.net.cn

选择spring.shell.command.help.command-template默认为classpath:template/help-command-default.stg并传递CommandInfoModel作为模型。spring-doc.cadn.net.cn

表 1.GroupsInfoModel 变量
钥匙 描述

showGroupsspring-doc.cadn.net.cn

true如果启用了 Showing Groups。否则为 false。spring-doc.cadn.net.cn

groupsspring-doc.cadn.net.cn

commands 变量(请参阅 GroupCommandInfoModel 变量)。spring-doc.cadn.net.cn

commandsspring-doc.cadn.net.cn

commands 变量(请参阅 CommandInfoModel 变量)。spring-doc.cadn.net.cn

hasUnavailableCommandsspring-doc.cadn.net.cn

true如果有不可用的命令。否则为 false。spring-doc.cadn.net.cn

表 2.GroupCommandInfoModel 变量
钥匙 描述

groupspring-doc.cadn.net.cn

组的名称(如果已设置)。否则为空。spring-doc.cadn.net.cn

commandsspring-doc.cadn.net.cn

命令 (如果已设置)。否则为空。Type 是多值,请参阅 CommandInfoModel 变量spring-doc.cadn.net.cn

表 3.CommandInfoModel 变量
钥匙 描述

namespring-doc.cadn.net.cn

命令的名称(如果已设置)。否则为 null。类型为 string 并包含 full 命令。spring-doc.cadn.net.cn

namesspring-doc.cadn.net.cn

命令的名称(如果已设置)。否则为 null。类型本质上是多值name分裂。spring-doc.cadn.net.cn

aliasesspring-doc.cadn.net.cn

可能的别名(如果已设置)。类型是带字符串的多值。spring-doc.cadn.net.cn

descriptionspring-doc.cadn.net.cn

命令的描述(如果已设置)。否则为 null。spring-doc.cadn.net.cn

parametersspring-doc.cadn.net.cn

parameters 变量(如果已设置)。否则为空。Type 是多值,请参阅 CommandParameterInfoModel 变量spring-doc.cadn.net.cn

availabilityspring-doc.cadn.net.cn

可用性变量(请参阅 CommandAvailabilityInfoModel 变量)。spring-doc.cadn.net.cn

表 4.CommandParameterInfoModel 变量
钥匙 描述

typespring-doc.cadn.net.cn

参数的类型(如果已设置)。否则为 null。spring-doc.cadn.net.cn

argumentsspring-doc.cadn.net.cn

参数(如果已设置)。否则为 null。类型是带字符串的多值。spring-doc.cadn.net.cn

requiredspring-doc.cadn.net.cn

true如果需要。否则为 false。spring-doc.cadn.net.cn

descriptionspring-doc.cadn.net.cn

参数的描述 (如果已设置)。否则为 null。spring-doc.cadn.net.cn

defaultValuespring-doc.cadn.net.cn

参数的默认值 (如果已设置)。否则为 null。spring-doc.cadn.net.cn

hasDefaultValuespring-doc.cadn.net.cn

true如果存在 defaultValue。否则为 false。spring-doc.cadn.net.cn

表 5.CommandAvailabilityInfoModel 变量
钥匙 描述

availablespring-doc.cadn.net.cn

true如果可用。否则为 false。spring-doc.cadn.net.cn

reasonspring-doc.cadn.net.cn

如果设置了 not available (如果已设置),则为原因。否则为 null。spring-doc.cadn.net.cn


APP信息