|
此版本仍在开发中,尚未被认为是稳定版。请使用最新稳定版 Spring Shell 4.0.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();
}
}
以下屏幕录像展示了确认组件的典型输出:
The context object是ConfirmationInputContext。以下表格描述了其上下文变量:
| 键 | 描述 |
|---|---|
|
默认值——要么是 |
|
The parent context variables (see TextComponentContext 模板变量). |