On Friday, Dec 20, 2002, at 15:19 US/Eastern,
... thoughts on doing a cvs style CLI deleted ...
> It gets tricky when you want to specify the input format and/or
> context as well. One way is to use options::
> docutils html --reader pep ...
I like this and was going to suggest it when I had a moment to breath
I have done many, many, many command line tools that use a user
interface of this nature. Total win-- easy to develop, easy to use,
easy to extend, and-- in the case of python-- makes it trivial to embed
the program (just construct an array of args and call the appropriate
main() directly with something other than sys.argv as the arglist).
The above situation is not that tricker, if done right. First,
consider the basic CLI format:
python <python options> docutils <docutils global options> command
<command specific options>
Now, in the above case, you have a command specific option that can
also have options. In this case, I suggest following the pattern of
the 'mount' command. That is:
--reader pep,--option1,--option2=1234,--option3,-d,-v --writer
And, of course, if you need spaces in that string, just stick quotes
around it. Commas are a problem...
I have done this in the past. It isn't exactly pretty, but this
complex of a CLI has to make a sacrifice somewhere. Most importantly,
it works and scales easily. Just split the argument to --reader on
',', yank the first arg to find the reader module, and pass the rest as
an array of args....