abiosoft / ishell

Library for creating interactive cli applications.
MIT License
1.69k stars 196 forks source link

When AddCmd.Completer() returns an array with many strings, auto-completion prints a lot of text #101

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi.

First, I would like to say that the ishell module is great and very easy to use :)

Mu problem description: I wrote a simple CLI and I added an auto-completion to one of my commands. The command.Completer() method returns an array with many entries (~50K), but there is a very low number of prefixes common to them.

When I press the "tab", after I'm writing the command token, the auto-complete prints all those options, and this takes a lot of time...

Is there is a better way to handle this? It would have been nice if only the prefixes would have printed and not all of the options.

Thank you Dotan

abiosoft commented 6 years ago

I have to admit I didn't have complex use case at the time and simply came up with something that worked for my use case.

The alternative would be to implement readline.AutoCompleter directly.

Is your code public? Or can you share a snippet that led to that scenario. That will help me in working towards something better.

ghost commented 6 years ago

Hi.

Thanks for the rapid response.

I added a python script that generates a go source which demonstrates the problem and a generated file, I hope that this will help you.

generate_code.zip