对于最新的稳定版本,请使用 Spring Shell 3.3.3spring-doc.cadn.net.cn

交互模式

命令注册可以定义InteractionMode用于隐藏命令 取决于正在执行的模式 shell。更多相关信息,请参见 交互模式.spring-doc.cadn.net.cn

您可以通过以下方式定义它CommandRegisration.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() {
}