该版本仍在开发中,尚未被视为稳定。最新稳定版本请使用Spring Shell 3.4.1spring-doc.cadn.net.cn

交互模式

命令注册可以定义交互模式用于隐藏命令 这取决于壳体执行的模式。更多内容请参见互动模式spring-doc.cadn.net.cn

你可以用 定义交互模式指挥注册:spring-doc.cadn.net.cn

CommandRegistration commandRegistration() {
	return CommandRegistration.builder()
		.command("mycommand")
		// can be defined for all modes
		.interactionMode(InteractionMode.ALL)
		// can be defined only for interactive
		.interactionMode(InteractionMode.INTERACTIVE)
		// can be defined only for non-interactive
		.interactionMode(InteractionMode.NONINTERACTIVE)
		.build();
}

或者用@ShellMethod.spring-doc.cadn.net.cn

@ShellMethod(key = "mycommand", interactionMode = InteractionMode.INTERACTIVE)
public void mycommand() {
}