パス入力

パス入力コンポーネントは、ユーザーに 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 テンプレート変数を参照)。