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

Interactive completion for positional arguments not working

Open C-Otto opened this issue 2 years ago • 8 comments
trafficstars

I migrated my code from version 2.0 to 3.1.5. Both with the new @Command syntax and with the old @ShellMethod variant I fail to get tab completion to work when I do NOT specify the parameter name via "--value". Everything works as expected when I add "--value" before the to-be-completed value.

This works: someCommand --value val<tab>

This does not work: someCommand val<tab>

With @ShellMethod (BarProvider implements ValueProvider):

@ShellMethod("description")
public String someCommand(
        @ShellOption(valueProvider = BarProvider.class) SomeType value
)

With @Command (BarProvider implements CompletionProvider):

@Command(description = "description")
public String someCommand(
        @Option(required = true, arity = EXACTLY_ONE) @OptionValues(provider = "barProvider") SomeType value
)

Am I missing something?

PS: Thanks for the resurrection of this project!

C-Otto avatar Nov 10 '23 09:11 C-Otto

Remind me how it works in your old shell version.

  • First tab gives you space
  • Second tab options where you can pick one, i.e. --arg1
  • Third tab then values for --arg1

gh923

https://github.com/spring-projects/spring-shell/blob/2d29050c340fceb4cc404bb457e9fafc28e221ca/spring-shell-samples/spring-shell-sample-commands/src/main/java/org/springframework/shell/samples/standard/CompleteCommands.java#L115-L122

jvalkeal avatar Nov 13 '23 09:11 jvalkeal

In my case I'm typing the command without completion, then add the prefix of the value before pressing TAB: someCommand val<tab>

With the old version this changes to someCommand value (assuming val is completed to value). I only have to press TAB once.

C-Otto avatar Nov 13 '23 10:11 C-Otto

In your example it would be complete sample4 E<tab>, which should show the three possible values (or complete if only one option fits).

C-Otto avatar Nov 13 '23 10:11 C-Otto

Right thanks for pointing it out. It indeed works via positional argument so completion should work as well.

jvalkeal avatar Nov 13 '23 10:11 jvalkeal

@C-Otto - I'm also hitting this issue, did you find a workaround?

paulalexwilson avatar Mar 31 '24 16:03 paulalexwilson

No

C-Otto avatar Mar 31 '24 16:03 C-Otto

Also seeing this and Im using annotations @ShellOption - does the framework have the notion of argument only commands (e.g commands that just take arguments that aren't labelled with option tags) ? Is this on the roadmap ? Otherwise the autocompletion works very well, thanks for this !

kieronedwards avatar Apr 26 '24 00:04 kieronedwards