Arg decoding with a template?
Jim Dennis
jimd at vega.starshine.org
Sun Aug 5 21:08:10 EDT 2001
In article <rdeemts4mrarb8b5ghqieio68n1jv32tl1 at 4ax.com>,
Dale Strickland-Clark wrote:
>David Bolen <db3l at fitlinxx.com> wrote:
>>-- David
> I guess what I had in mind was a simple but effective equivelent that
> I used to use with BCPL. A function called rdargs, which I think also
> became part of AmigaDOS
For those of us who are unfamiliar with these; do you care to
show an example of the syntax and explain why you think it's superior?
> I've just had a quick hunt with Google and I can't find a definition
> for it anywhere.
> I'll probably end up using getopt just because I don't have time to
> do a proper job right now.
It might be possible to create a subclass of getopt which
provides a similar API (list of methods) but accepts your
preferred syntax.
BTW: It would be *REALLY* nice if you'd wrap you lines at <72 chars
and provide a leading space (margin) to your posts. 80 character
widths are still a dominant convention for USENET/netnews and
public mailing lists, and leaving a few characters for quoting
prefixes is always appreciated.
Someone in this thread mentioned the convenience of '?-completion'
on *switches* as well as filenames. Of course in the latest versions
of the popular UNIX/Linux shells there is support for "programmable
completion." However, it would be difficult to make that work with
arbitrary command arguments. I suppose one could emulate it with
a couple of features:
For each (known) command:
Build a list of known switches
Compile that into a database/dbm hash
On (tab completion):
if known:
match command (arg[0]) and
match/glob switch "head" on known switches
present a list of completions
else:
call command with --help:
grep for - lines that match current switch "head"
... That would be cool.
More information about the Python-list
mailing list