跳到主要内容

交互模式

ChatGPT-4o-mini 中英对照 Interaction Mode

命令注册可以定义 InteractionMode,用于根据 shell 正在执行的模式隐藏命令。有关更多信息,请参见 Interaction Mode

您可以使用 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();
}
java

或者使用 @ShellMethod

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