-
Bug
-
Resolution: Done
-
Major
-
1.11
-
None
-
None
We are currently using aesh to parse our CLI options and not as a shell.
We are using nested GroupCommand annotations:
- gp-main (main group command)
- gp-sub (secondary group command that belongs to gp-main)
- command (command that belongs to gp-sub)
While setting things up (reproducer project is in the attachment), I noticed that 'gp-sub' is treated as a main group command and can be invoked without using 'gp-main' first.
# OK <cli> gp-main gp-sub --help # NOT OK but currently works <cli> gp-sub --help
This breaks the namespace we created for gp-sub under gp-main.
Snippets from the reproducer project:
Commands:
@GroupCommandDefinition(name = "gp-main", description = "test", groupCommands = {SubGroupCommand.class}) public static class GroupCommand extends CommandHelper { } @GroupCommandDefinition(name = "gp-sub", description = "sub group", groupCommands = {MainCommand.class}) public static class SubGroupCommand extends CommandHelper { } @CommandDefinition(name = "command", description = "main command") public static class MainCommand extends CommandHelper { ... }
CommandHelper implements Command and helps provides some helper methods.
Aesh setup
CommandRegistry registry = new AeshCommandRegistryBuilder()
.command(GroupCommand.class)
.command(SubGroupCommand.class)
.command(MainCommand.class)
.create();
CommandRuntime runtime = AeshCommandRuntimeBuilder
.builder()
.commandRegistry(registry)
.build();
If I remove:
.command(SubGroupCommand.class)
.command(MainCommand.class)
from the above code, this works but it break the commandInvocation.getHelpInfo method.
Reproducer
1. Unzip the project
2. Build via: mvn clean install
3. Run via: java -jar target/aesh-experiment-1.0-SNAPSHOT-jar-with-dependencies.jar
Output of reproducer
--------------------------------------
running: gp-main --help
Usage: gp-main
test
Options:
-h, --help print help
gp-main commands:
gp-sub sub group
--------------------------------------
--------------------------------------
That shouldn't work since it is not a top-level group command
--------------------------------------
running: gp-sub --help
Usage: gp-sub
sub group
Options:
-h, --help print help
gp-sub commands:
command main command
--------------------------------------
Expected behaviour
I don't want gp-sub to be able to be invoked from the 'top-level', but can only be invoked under 'gp-main'.