remkop / picocli

Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
https://picocli.info
Apache License 2.0
4.81k stars 414 forks source link

[Question] Is it possible to get suggestion list dynamically? #2314

Closed nqminhuit closed 5 days ago

nqminhuit commented 1 week ago

For example, when i type:

git checkout <Tab>

It list all they branches on my current git repo. Is this usecase possible with picocli?

remkop commented 1 week ago

Hi @nqminhuit , have you had a chance to read this?

https://picocli.info/autocomplete.html

nqminhuit commented 1 week ago

thank you for your quick reply, so it's possible then, I will try to learn more about it.

remkop commented 1 week ago

There's JLine and bash completion. Dynamic completion is easier with JLine.

It's possible with bash but you would have to customize the bash completion script generated by picocli. So picocli would only do the first half...

nqminhuit commented 1 week ago

So if I use bash completion, I have to write additional bash functions for the dynamic parts?

remkop commented 5 days ago

Yes probably.