互動模式

命令註冊可以定義 InteractionMode,用於根據 shell 正在執行的模式隱藏命令。有關更多資訊,請參閱互動模式

您可以使用 CommandRegisration 來定義它。

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

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