-
Notifications
You must be signed in to change notification settings - Fork 393
Closed
Labels
type/bugIs a bug reportIs a bug report
Milestone
Description
Consider this configuration:
@SpringBootApplication
public class SpringShellApplication {
public static void main(String[] args) {
SpringApplication.run(SpringShellApplication.class, args);
}
@Command(name = "hello", completionProvider = "helloNameCompletionProvider")
public void sayHello(@Option(longName = "name", shortName = 'n') String name) {
System.out.println("Hello " + name + "!");
}
@Bean
public CompletionProvider helloNameCompletionProvider() {
return completionContext -> {
CommandOption option = completionContext.getCommandOption();
if (option == null) {
return Collections.emptyList();
}
if ("name".equals(option.longName()) || 'n' == option.shortName()) {
return Stream.of("Peter", "Paul", "Mary").map(CompletionProposal::new).toList();
}
return Collections.emptyList();
};
}
}Step to reproduce:
- Type
hello - Press
Taband select--nameor-noption - Press
Tabagain and observe that no completion proposal is shown.
This is caused because no command option is provided within completion context so completionContext.getCommandOption() is always null.
fmbenhassine
Metadata
Metadata
Assignees
Labels
type/bugIs a bug reportIs a bug report