This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andybuckley
Recipients andybuckley, gruszczy, wplappert
Date 2010-04-03.14:22:00
SpamBayes Score 2.0568436e-11
Marked as misclassified No
Message-id <1270304523.43.0.288930201363.issue4256@psf.upfronthosting.co.za>
In-reply-to
Content
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.:

gruszczy@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!
History
Date User Action Args
2010-04-03 14:22:03andybuckleysetrecipients: + andybuckley, wplappert, gruszczy
2010-04-03 14:22:03andybuckleysetmessageid: <1270304523.43.0.288930201363.issue4256@psf.upfronthosting.co.za>
2010-04-03 14:22:01andybuckleylinkissue4256 messages
2010-04-03 14:22:00andybuckleycreate