I have a CLI program that has a few nested subcommands, like
program task
program task start
program task stop
program config
program config set
program config unset
And I'd like to implement a very rudimentary bash autocomplete for it. I don't necessarily want to go the route of defining a shell-function for it, but was hoping to simply use wordlists, like
complete -W "task config" -- "program"
But it doesn't seem I can define nested completion wordlists that way, like
complete -W "start stop" -- "program task"
complete -W "set unset" -- "program config"
Is there a simple way of achieving autocompletion for such commands?
Here's an example of the _get_comp_words_by_ref function I mentioned in my comments.
Source this file and try typing program co[TAB], program config u[TAB], etc.