Search code examples
springspring-shell

Is there a way to define a ShellOption without value to check if it exists or not?


I'm using Spring Shell for one of my projects, and I need a parameter to run my command with a different behavior like --without-logs.

Basically I need a ShellOption parameter to check if the parameter is given by the user or not.

Example:

my-command --without-logs --other-opts

my-command --other-opts


Solution

  • I found the solution, by default Spring Shell assign the option to true if we use that like only by option name.

    Example:

    my-commnand --x -> x is true

    my-command --x false -> x is false