Fix alias handling with @Command annotation

- Revisit how alias commands are added using
  @Command annotation when using if/or on class
  and/or method level.
- With this change alias handling is more logical
  and there's better tests and docs.
- Fixes #945
This commit is contained in:
Janne Valkealahti
2024-01-13 12:19:12 +00:00
parent c0301933fd
commit a37bd6ad5a
8 changed files with 409 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,6 +50,11 @@ public class AliasCommands {
public String testAlias2Annotation() {
return "Hello from alias command";
}
@Command(command = "alias-3 alias-31", alias = "alias-32 alias-33")
public String testAlias3Annotation() {
return "Hello from alias3 command";
}
}
@Component
@@ -89,6 +94,22 @@ public class AliasCommands {
.and()
.build();
}
@Bean
public CommandRegistration testAlias3Registration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command(REG, "alias-3 alias-31")
.group(GROUP)
.withAlias()
.command(REG, "alias-32 alias-33")
.and()
.withTarget()
.function(ctx -> {
return "Hello from alias3 command";
})
.and()
.build();
}
}
}