For example, I have a python script "control_center.py" which takes the $1 (start stop reboot) as command, and extra options (-a foo/bar).
control_center.py [start|stop|reboot] -a [foo|bar]
I have used argcomplete, it works fine with the options.
cotrol_center.py start -a <tap> <tap>
bar foo
However, the argcomplete can not auto fills the command (start|stop|reboot) for me.
I've tried to edit one bash complete script my self, it does can gives me the hint on the first argument, but it disabled the argcomplete at the same time.
control_center.py <tap> <tap>
start stop reboot
control_center.py start -a <tap> <tap>
# nothing pops out
What I want is something like below:
control_center.py <tap> <tap>
start stop reboot
control_center.py start -a <tap> <tap>
bar foo
Btw, here is my auto completion bash script.
#!/usr/bin/env bash
_control_center_completions()
{
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
COMPREPLY=($(compgen -W "start stop reboot" -- "${COMP_WORDS[1]}"))
}
complete -F _control_center_completions control_center.py
I wonder if I can do some modification on that script so the argcomplete won't be disabled.