spring-projects / spring-shell

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

MultiItemSelector and SingleItemSelector run not prompting user and returning immediately on Windows 11 #1015

Closed simonhillairetsrai closed 5 months ago

simonhillairetsrai commented 5 months ago

This issue occurs on Windows 11, using Windows command line cmd.exe.

Spring-shell version: 3.2.2

Based on the example provided in version 3.2.2 of the documentation:

https://docs.spring.io/spring-shell/reference/components/ui/multiselect.html

@ShellComponent
public class ComponentCommands extends AbstractShellComponent {

    @ShellMethod(key = "component multi", value = "Multi selector", group = "Components")
    public String multiSelector() {
        List<SelectorItem<String>> items = new ArrayList<>();
        items.add(SelectorItem.of("key1", "value1"));
        items.add(SelectorItem.of("key2", "value2", false, true));
        items.add(SelectorItem.of("key3", "value3"));
        MultiItemSelector<String, SelectorItem<String>> component = new MultiItemSelector<>(getTerminal(),
                items, "testSimple", null);
        component.setResourceLoader(getResourceLoader());
        component.setTemplateExecutor(getTemplateExecutor());
        MultiItemSelectorContext<String, SelectorItem<String>> context = component
                .run(MultiItemSelectorContext.empty());
        String result = context.getResultItems().stream()
                .map(si -> si.getItem())
                .collect(Collectors.joining(","));
        return "Got value " + result;
    }
}

When calling this command, the user is not prompted to select a value and context.getResultItems() returns null immediatly.

The same issue occurs with SingleItemSelector:

https://stackoverflow.com/questions/77335253/spring-shell-singleitemselector-not-working-in-windows-console-but-fine-in-ubu

jvalkeal commented 5 months ago

Is this same issue than in #976 not including spring-shell-starter-jna which is required in windows?

jvalkeal commented 5 months ago

At least running sample locally it works:

image

simonhillairetsrai commented 5 months ago

Thank you, adding the dependency spring-shell-starter-jna worked. As mentioned in #976 it would be nice if it was described in the documentation. Is there a way to open "tickets" for documentation ?