このバージョンはまだ開発中であり、まだ安定しているとは見なされていません。最新の安定バージョンについては、Spring Shell 3.4.1 を使用してください!

コマンドの編成

シェルが多くの機能を提供し始めると、最終的には多くのコマンドが必要になり、ユーザーを混乱させる可能性があります。help と入力すると、アルファベット順に整理された困難なコマンドのリストが表示されます。これは、使用可能なコマンドを表示する最良の方法ではない場合があります。

この混乱の可能性を軽減するために、Spring Shell はコマンドをグループ化する機能を提供し、適切なデフォルトを設定します。関連するコマンドは同じグループ (たとえば、User Management Commands) にまとめられ、ヘルプ画面やその他の場所に一緒に表示されます。

Commands can be grouped by specifying a group attribute in the @Command annotation:

@Command(name = "example", group = "My Commands")
public String example() {
    return "Hello";
}

The group can also be specified programmatically when using the programmatic registration model using the Command.Builder.group(String) method:

@Bean
Command myCommand() {
    return Command.builder()
            .name("mycommand")
            .group("My Commands")
            .execute(context -> {
                System.out.println("This is my command!");
            });
}