[Bash-completion-devel] Any common recipe for parsing command line options?

Alun Evans alun at badgerous.net
Fri Apr 30 06:22:01 UTC 2010


Hi,

I was wondering if there is any common recipe for adding completion for commands with arguments, e.g. say my format is:

 cmd [ -f | --file ] [ -o | --output ] [ -v | --verbose ]

if I do:

 cmd -<TAB>

I'd like to generate:
  -f --file -o --output -v --verbose

but if I do:

 cmd -f foo -<TAB>
or:
 cmd --file foo -<TAB>

I'd like to see:
  -o --output -v --verbose

I could cook something up, but I'm thinking this is a very common task, and wondering if it's been done already.


Hmm, I guess this is some kind of getopts style...


thanks,


A.

-- 
Alun Evans



More information about the Bash-completion-devel mailing list