|
该版本仍在开发中,尚未被视为稳定。最新稳定版本请使用Spring Shell 3.4.1! |
路径输入
路径输入组件会向用户请求路径并提供关于路径本身的额外信息。
@Command
public class ComponentCommands extends AbstractShellComponent {
@Command(command = "component path input", description = "Path input", group = "Components")
public String pathInput() {
PathInput component = new PathInput(getTerminal(), "Enter value");
component.setResourceLoader(getResourceLoader());
component.setTemplateExecutor(getTemplateExecutor());
PathInputContext context = component.run(PathInputContext.empty());
return "Got value " + context.getResultValue();
}
}
以下屏幕显示了路径输入组件的典型输出:
上下文对象为路径输入上下文.下表描述了其上下文变量:
| 钥匙 | 描述 |
|---|---|
|
父上下文变量(参见TextComponentContext模板变量)。 |