by m463 · 4y ago · 0 comments
It would almost be easier to modify the bash source itself to read and use a regular grammar, say:
foo [-p <pid>] [-f <configfile>]
<pid>: {ps -eo pid}
<configfile>: {ls -1 *.cfg}
or maybe something even nicer with help textAlthough it's not ideal (one ends up duplicating the arguments parsing logic of the program), it's actually not complicated, just some boilerplate.
complete -o nospace -C 'domterm "#complete-for-bash" "$COMP_LINE" "$COMP_POINT"' domterm
It works pretty well has the advantage that it automatically ties the completion to the executable, avoiding version mismatches.It would be great if other shells could use a similar mechanism. Then you could use the same completion logic for multiple shells. A complication is that zsh and fish completion provide descriptive help text; there would need to be a mechanism for a "completion option" to provide such help text.
It's an interesting idea that we're using for zio-cli [1].