[getopt-sig] ObjectCLI

Greg Ward gward@python.net
Wed, 20 Feb 2002 10:00:56 -0500


[Shane, on how to write programs that don't use the sub-command paradigm]
> It doesn't work in the current prototype, but instead of passing an
> instance, you just pass a function.

OK, that makes sense, and it's consistent with your answer to "How do
you implement ls?":

[me]
>   ls -Fa /home/greg
>   ls -l *.py

[Shane]
> def ls(F=None, a=None, l=None, *filenames):
>   ...

But it means *really* implement ls -- which on my system has 40
one-letter options and 37 long options, many of which are synonyms for
short options -- is impractical.

[me again]
> Also, what if I want to make -p and --port synonomous?  How do I
> express that?

[Shane]
> I'm sure we differ on this, but for me (and perhaps others), that is not a
> goal.

OK, then you're obviously uninterested in implementing something like
ls.  That's fine.

[Shane]
> I'm pretty sure you and I have different goals.  I think your main goal is
> to create a featureful option parser that does a better job than getopt.
> My main goal is to eliminate the work of parsing options altogether,
> possibly sacrificing some flexibility.  The differing goals result in very
> different mindsets.  I'd like to know what other people's goals are.

Right, I want to be able to implement the normal, sensible, conventional
GNU/Unix command-line syntax in every script I write with minimal fuss
and bother.  I want this mechanism to be flexible, extensible, and in
the standard library.  I don't think a solution that sacrifices
flexibility belongs in the standard library; things like having short
and long options that mean the same thing are just too important.
Strong typing and automatically generated help for each option are also
really nice.

More fundamentally, I think it's unrealistic to think that you can
eliminate the work of parsing options altogether.  Smells like wishful
thinking.  Anyways, I have convinced myself -- by writing Optik -- that
it's possible to make the work of option parsing very easy and
unobtrusive.  

        Greg
-- 
Greg Ward - Linux weenie                                gward@python.net
http://starship.python.net/~gward/
Jesus Saves -- and you can too, by redeeming these valuable coupons!