paul j3 added the comment:

Regarding a usage line like:

    (-o FILE | (-O DIR & (-p PATTERN | -s SUFFIX))

The simplest option is to just a custom written 'usage' parameter.

With the existing HelpFormatter, a nested grouping like this is next to 
impossible.  It formats the arguments (e.g.'-O DIR'), interleaves the group 
symbols, and then trims out the excess spaces and symbols.

http://bugs.python.org/issue10984  is a request to allow overlapping 
mutually_exclusive_groups.  It loops on the groups, formatting each.  It would 
be easier with that to format several different types of groups, and to handle 
nested ones.

What would it take to convert a usage string like that into a logical 
expression that tests for the proper occurrence (or non-occurrence) of the 
various arguments.  It might, for example be converted to

    exc(file, inc(dir, exc(pattern, suffix)))

where 'exc' and 'inc' are exclusive and inclusive tests, and 'file','dir' etc 
are booleans.  And what would be the error message(s) if this expression fails?

I can imagine a factory function that would take usage line (or other 
expression of groupings), and produce a function that would implement a 
cross_test (as outlined in my previous post).  It would be, in effect, a 
micro-language compiler.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11588>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to