このバージョンはまだ開発中であり、まだ安定しているとは見なされていません。最新の安定バージョンについては、Spring Shell 3.4.1 を使用してください! |
確認
確認コンポーネントは、ユーザーに簡単な確認を求めます。それは本質的にイエスかノーの質問です。
public class ComponentCommands {
@Command(name = "component confirmation", description = "Confirmation input", group = "Components")
public String confirmationInput(boolean no) {
ConfirmationInput component = new ConfirmationInput(getTerminal(), "Enter value", !no);
ResourceLoader resourceLoader = null; // getResourceLoader();
TemplateExecutor templateExecutor = null; // getTemplateExecutor();
component.setResourceLoader(resourceLoader);
component.setTemplateExecutor(templateExecutor);
ConfirmationInputContext context = component.run(ConfirmationInputContext.empty());
return "Got value " + context.getResultValue();
}
}次のスクリーンキャストは、確認コンポーネントからの一般的な出力を示しています。
コンテキストオブジェクトは ConfirmationInputContext です。次の表に、そのコンテキスト変数を示します。
| キー | 説明 |
|---|---|
| デフォルト値 — |
| 親コンテキスト変数 ( TextComponentContext テンプレート変数を参照)。 |