Skip to content
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

Inconsistent behaviour on passing invalid argument #1120

Closed
kulkarnipradnyas opened this issue Aug 16, 2024 · 1 comment
Closed

Inconsistent behaviour on passing invalid argument #1120

kulkarnipradnyas opened this issue Aug 16, 2024 · 1 comment
Labels
branch/3.2.x Issue for a branch branch/3.3.x Issue for a branch for/backport For backporting type/bug Is a bug report
Milestone

Comments

@kulkarnipradnyas
Copy link

@Command(command = "activate", group = "Activate/Deactivate Commands")
public class ActivationCommand {
    @Command(command = "test", description = "test")
    public void activateTest(
            @Option(longNames = "id", required = true, description = "test ID") Long id,
            @Option(longNames = "name", required = true, description = "test name") String name
            ){
        System.out.println("Activating test with id: " + id+ name);
    }
}

For the above code, I am getting the below inconsistent result. When an invalid argument is passed as a first argument then the shell throws an error log but when it is passed at the end it just ignores that. It should throw an error log on both cases.

Screenshot 2024-08-16 at 1 04 54 PM Screenshot 2024-08-16 at 1 05 40 PM
@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Aug 16, 2024
@jvalkeal jvalkeal added type/bug Is a bug report and removed status/need-triage Team needs to triage and take a first look labels Aug 16, 2024
@jvalkeal
Copy link
Contributor

Thanks for reporting. Looks like --invalid and true are passed to name option as an arguments in this case. That's clearly wrong.

@jvalkeal jvalkeal added this to the 3.4.0-M1 milestone Aug 19, 2024
@jvalkeal jvalkeal added for/backport For backporting branch/3.2.x Issue for a branch branch/3.3.x Issue for a branch labels Aug 19, 2024
jvalkeal added a commit that referenced this issue Aug 19, 2024
- Fix an issue where unknown option is wrongly
  lexed as an argument if it's later than an known
  valid option.
- Essentially if `arg1` is only valid option
  `--arg1 value1 --arg2 value2` would not complain
  about `arg2`.
- Backport #1120
- Fixes #1123
jvalkeal added a commit that referenced this issue Aug 19, 2024
- Fix an issue where unknown option is wrongly
  lexed as an argument if it's later than an known
  valid option.
- Essentially if `arg1` is only valid option
  `--arg1 value1 --arg2 value2` would not complain
  about `arg2`.
- Backport #1120
- Fixes #1122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch/3.2.x Issue for a branch branch/3.3.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