互動模式
命令註冊可以定義 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() {
}