spring-projects / spring-shell

Spring based shell
http://projects.spring.io/spring-shell/
Apache License 2.0
710 stars 391 forks source link

Interactive completion for positional arguments not working #923

Open C-Otto opened 8 months ago

C-Otto commented 8 months ago

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!

jvalkeal commented 8 months ago

Remind me how it works in your old shell version.

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

C-Otto commented 8 months ago

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 commented 8 months ago

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

jvalkeal commented 8 months ago

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

paulalexwilson commented 3 months ago

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

C-Otto commented 3 months ago

No

kieronedwards commented 2 months ago

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 !