命令注册可以定义用于隐藏命令的命令 取决于 shell 正在执行的模式。在交互模式中对此有更多了解。InteractionModeSpring中文文档

您可以使用 来定义它。CommandRegisrationSpring中文文档

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();
}

或者用 .@ShellMethodSpring中文文档

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