Ben Finney wrote:
> icarus <rsa...@gmail.com> writes:
> 
>>      parser = optparse.OptionParser(usage="%prog [-p dir] [--part=dir] ",
>> version="%prog 1.0")
>>
>>      parser.add_option( "-p", "--part", dest="directory",
>>                        help="process target directory", metavar="dir")
>>      (options, args) = parser.parse_args()

...

>>      if len(args) != 1:
>>              parser.error("No options specified")
> 
> The message is confusing, since it doesn't match the condition; it would
> be correct to say “Did not specify exactly one non-option argument”.
> 
> In this case, it looks like you don't want to check this at all, and
> should instead operate on the basis of the options only.

I also wanted to note that it looks quite illogical and
counter-intuitive to create "required options", since by definition they
should be optional.
Try using arguments instead, with some type-switching flags, if
necessary - it should make CLI more consistent and save some typing by
omitting otherwise always-required option argument ("--part").

-- 
Mike Kazantsev // fraggod.net

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to