路径输入

路径输入组件要求用户输入一个 Path,并提供有关路径本身的附加信息。

@ShellComponent
public class ComponentCommands extends AbstractShellComponent {

	@ShellMethod(key = "component path input", value = "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();
	}
}

以下截屏显示了路径输入组件的典型输出

上下文对象是 PathInputContext。下表描述了其上下文变量

表 1. PathInputContext 模板变量
描述

model

父上下文变量(参见TextComponentContext 模板变量)。

© . This site is unofficial and not affiliated with VMware.