spring-shell icon indicating copy to clipboard operation
spring-shell copied to clipboard

Support arg=value format with options

Open Martiul opened this issue 1 year ago • 2 comments
trafficstars

Hello,

I recently upgraded from spring-shell 2.7.5 to 3.2.0, and found that arguments of the form "arg=value" are no longer accepted.

Is this a regression, or was it intended?

Sample code:

  @ShellMethod(
      value = "Description",
      key = {"test"})
  public void test(
      @ShellOption(
          value = {"--foo", "-f"},
          defaultValue = ShellOption.NULL) String foo) {
    System.out.println("Foo is: " + foo);
  }

shell:> test --foo=bar

Expected:

Foo is: bar

Actual:

Unrecognised option '--foo=bar'

Martiul avatar Jan 18 '24 20:01 Martiul

Thanks for pointing this out. It wasn't implemented when parser infra went through complete overhaul.

I'm just thinking that when we add support for this should we be explicit which formats are supported, --arg value vs. --arg=value. It might be convenient to allow user to choose either or both.

jvalkeal avatar Jan 19 '24 09:01 jvalkeal

Thanks for the response @jvalkeal . For me specially, this is not a blocking/urgent bug, but figured it was worth mentioning in case other users do the same migration

Martiul avatar Jan 19 '24 15:01 Martiul