|
该版本仍在开发中,尚未被视为稳定。最新稳定版本请使用Spring Shell 3.4.1! |
确认
确认部分要求用户提供简单的确认。它本质上是 是或不是问题。
@Command
public class ComponentCommands extends AbstractShellComponent {
@Command(command = "component confirmation", description = "Confirmation input", group = "Components")
public String confirmationInput(boolean no) {
ConfirmationInput component = new ConfirmationInput(getTerminal(), "Enter value", !no);
component.setResourceLoader(getResourceLoader());
component.setTemplateExecutor(getTemplateExecutor());
ConfirmationInputContext context = component.run(ConfirmationInputContext.empty());
return "Got value " + context.getResultValue();
}
}
以下屏幕显示了确认组件的典型输出:
上下文对象为确认输入上下文.下表描述了其上下文变量:
| 钥匙 | 描述 |
|---|---|
|
默认值—— |
|
父上下文变量(参见TextComponentContext模板变量)。 |