Andy Buckley <a...@insectnation.org> added the comment:

That sort of idea, yes: just a wild thought, but it would be really nice if 
this was available so that in combination with a standard bash/zsh function, 
getting basic automatic command completion for scripts built with optparse (and 
any other implementer of such a scheme) was as simple as adding

complete -F _optparse -o default mycmdname

to the completion script library.

The simple scheme you laid out seems fine to me, but in the best bikeshedding 
tradition it would be useful to distinguish between options which take an 
argument and those which don't, pre-empt the need for a format version, and 
make the parsing even easier by removing cosmetic whitespace, commas etc.:

grusz...@gruszczy-laptop:~/Programs/logbuilder$ ./logbuilder --help-options
#OPTPARSE_FORMAT 0
--version
-h --help
-r= --regexp=
-c= --contains=
-s= --start=
-e= --end=
-f= --file=
-t= --template=
-p= --purge=

Maybe this is just a pipe-dream, but the need to hand-write basic completion 
scripts seems so unnecessary, just for lack of any (even de-facto) 
standardisation. As optparse already enforces/encourages many good habits and 
conventions, some system like this would further help the integration with 
shell completion.

Or maybe the existing --help output is good enough for a rather more fiddly 
standard bash completion parsing function. I've tried writing one of these, but 
it would hard for it be generally robust since the descriptive strings can 
contain any structure that they feel like, and could hence mess up the 
pattern-matching. I'm very happy if someone can out-sed me and make that work!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4256>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to