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