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

Positional options should be configurable with annotations

Open jvalkeal opened this issue 2 years ago • 0 comments
trafficstars

CommandRegistration allows to define position info for an option. This is nice if user wants to have a feature to work without actual option names but also introduces difference for default functionality for annotation vs. programmatic registration.

This can be seen from a sample app:

my-shell:>e2e anno optional-value 
Hello null
my-shell:>e2e anno optional-value --arg1 asdf
Hello asdf
my-shell:>e2e anno optional-value asdf
Hello asdf

my-shell:>e2e reg optional-value
Hello null
my-shell:>e2e reg optional-value --arg1 asdf
Hello asdf
my-shell:>e2e reg optional-value asdf
Hello null

StandardMethodTargetRegistrar will automatically add positional info as it scans methods and its parameters, so it knows what positions to use. However force feeding this is not so nice!

Think about adding a global flag and/or tweaking current annotations to define it per command method. Need to be a bit careful what comes for changing existing @ShellMethod or @ShellOption annotations as completely new annotation model is about to get designed.

jvalkeal avatar Jan 07 '23 09:01 jvalkeal