最新の安定バージョンについては、Spring Shell 3.4.1 を使用してください! |
ヘルプ
シェルアプリケーションの実行は、多くの場合、ユーザーがグラフィカルに制限された環境にいることを意味します。また、携帯電話の時代にはほぼ常に接続されていますが、Web ブラウザーやその他のリッチ UI アプリケーション (PDF ビューアーなど) へのアクセスは常に可能であるとは限りません。これが、シェルコマンドが正しく自己ドキュメント化されていることが重要である理由であり、これが help コマンドの出番です。
help + ENTER と入力すると、シェルで認識されているすべてのコマンド ( 使用できないコマンドを含む) と、それらの機能の簡単な説明が次のように一覧表示されます。
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> と入力すると、使用可能なパラメーター、その型、必須かどうか、その他の詳細を含む、コマンドに関するより詳細な情報が表示されます。
次のリストは、それ自体に適用された help コマンドを示しています。
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] ヘルプはテンプレート化されており、必要に応じてカスタマイズできます。設定は、enabled を使用してコマンドを無効にする spring.shell.command.help にあり、構造を平坦化してグループを非表示にする場合は group または flat を取る grouping-mode、コマンドヘルプの出力用のテンプレートを定義する command-template、コマンドリストの出力を定義する commands-template です。
spring.shell.command.help.grouping-mode=flat が設定されている場合、ヘルプは次のように表示されます。
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> からの出力は両方とも、変更可能なデフォルトの実装でテンプレート化されています。
オプション spring.shell.command.help.commands-template のデフォルトは classpath:template/help-commands-default.stg で、モデルとして GroupsInfoModel が渡されます。
オプション spring.shell.command.help.command-template のデフォルトは classpath:template/help-command-default.stg で、モデルとして CommandInfoModel が渡されます。
| キー | 説明 |
|---|---|
|
|
| コマンド変数 ( GroupCommandInfoModel 変数を参照)。 |
| コマンド変数 ( CommandInfoModel 変数を参照)。 |
|
|
| Key | Description |
|---|---|
| グループの名前 (設定されている場合)。それ以外の場合は空です。 |
| コマンド (設定されている場合)。それ以外の場合は空です。型は複数の値です。CommandInfoModel 変数を参照してください。 |
| キー | 説明 |
|---|---|
| コマンドの名前 (設定されている場合)。それ以外の場合は null。型は文字列で、完全なコマンドが含まれています。 |
| 設定されている場合、コマンドの名前。それ以外の場合は null。型は基本的に |
| 可能なエイリアス (設定されている場合)。型は文字列の複数値です。 |
| コマンドの説明 (設定されている場合)。それ以外の場合は null。 |
| パラメーター変数 (設定されている場合)。それ以外の場合は空です。型は複数の値です。CommandParameterInfoModel 変数を参照してください。 |
| 可用性変数 ( CommandAvailabilityInfoModel 変数を参照)。 |
| キー | 説明 |
|---|---|
| 設定されている場合のパラメーターの型。それ以外の場合は null。 |
| 引数 (設定されている場合)。それ以外の場合は null。型は文字列の複数値です。 |
|
|
| パラメーターの説明 (設定されている場合)。それ以外の場合は null。 |
| パラメーターのデフォルト値 (設定されている場合)。それ以外の場合は null。 |
|
|
| Key | Description |
|---|---|
|
|
| 設定されている場合、利用できない場合の理由。それ以外の場合は null。 |