交互模式
命令注册可以定义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() {
}