-
Notifications
You must be signed in to change notification settings - Fork 393
Boolean flags not working without value in sub-commands #1331
Copy link
Copy link
Closed
Labels
type/bugIs a bug reportIs a bug report
Milestone
Description
This is a follow-up to #1309 but it's specific to sub-commands.
Steps taken
Consider the following application which with a command test with a sub-command sub-test which has an optional flag, i.e. a boolean argument, of name --force:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.shell.core.command.annotation.Command;
import org.springframework.shell.core.command.annotation.Option;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Command(name = "test sub-test")
public void test(@Option() boolean force) {
System.out.println("force = " + force);
}
}Expected behaviour
❯ ./mvnw -q spring-boot:run
...
$>test sub-test
force = false
$>test sub-test --force true
force = true
$>test sub-test --force
force = true
Actual behaviour
⚡ Error while parsing command: Option '--force' requires a value
❯ ./mvnw -q spring-boot:run
...
$>test sub-test
force = false
$>test sub-test --force true
force = true
$>test sub-test --force
Error while parsing command: Option '--force' requires a value
edit: I was able to confirm this on 4.0.1 and 4.0.2-SNAPSHOT (9dbdd71).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type/bugIs a bug reportIs a bug report