Skip to content

Aliases not working as expected with Annotations #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iheffernan opened this issue Jun 21, 2023 · 1 comment
Closed

Aliases not working as expected with Annotations #796

iheffernan opened this issue Jun 21, 2023 · 1 comment
Labels
branch/3.1.x Issue for a branch for/backport For backporting type/bug Is a bug report
Milestone

Comments

@iheffernan
Copy link

iheffernan commented Jun 21, 2023

When using Legacy Annotations, I am able to annotate a method as such:

@ShellMethod(value = "Exit the shell.", key = {"logout","quit", "exit"})

and the corresponding help message properly parses the multiple method aliases:

logout, quit, exit: Exit the shell.

However, when using the new @Option annotation, the help and parsing get garbled:

@Command(description = "Exit the shell", alias = {"logout","quit", "exit"})

logout, logout quit exit: Exit the shell

as you can see, all the aliases are crammed together into a single space-separated alias.

Am I misunderstanding the alias property? If so, what is the correct way to accomplish what is currently available in the Legacy Annotation? NOTE: I have also tried using an array of command values and I get a similar result:

@Command(description = "Exit the shell", command = {"logout","quit", "exit"})

yields

logout quit exit: Exit the shell

Using Spring Shell v3.1.1

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Jun 21, 2023
@jvalkeal jvalkeal added type/bug Is a bug report and removed status/need-triage Team needs to triage and take a first look labels Jun 22, 2023
@jvalkeal
Copy link
Contributor

Thanks for pointing out misbehaviour with @Command and help page template.

@jvalkeal jvalkeal modified the milestones: 3.1.x, 3.2.0-M1 Jun 22, 2023
@jvalkeal jvalkeal added for/backport For backporting branch/3.1.x Issue for a branch labels Jun 22, 2023
jvalkeal added a commit that referenced this issue Jun 22, 2023
- Fix alias command extraction from existing @command
  annotations so that we actually get multiple aliases
  defined if more than one defined on a method level.
- Fix rendering issue in a help stg template when
  multiple aliases exists.
- Backport #796
- Fixes #798
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch/3.1.x Issue for a branch for/backport For backporting type/bug Is a bug report
Projects
None yet
Development

No branches or pull requests

2 participants