plac 0.5 is out!
Andre Alexander Bell
post at andre-bell.de
Sun Jun 20 14:26:47 EDT 2010
On 06/20/2010 11:22 AM, Michele Simionato wrote:
> A few weeks ago I presented on this list my most recent effort, plac.
> Now there is a *huge* new release:
> the size of plac and of its documentation doubled.
> [...]
>
> http://micheles.googlecode.com/hg/plac/doc/plac.html
I've read this one...
> http://micheles.googlecode.com/hg/plac/doc/plac_ext.html
But this one is broken. :(
How about hierarchical composition. I've seen several scripts following
the format
basescript command [options] subcommands [other optiones] ...
It would be great if one can compose functions to form the commands.
Instead of
def main(command, opt1, opt2):
"""..."""
if command == 'cmd1':
...
elif command == 'cmd2':
...
if __name__=='__main__':
import plac
plac.call(main)
one could then write
def cmd1(opt1):
"""..."""
...
def cmd2(opt2):
"""..."""
...
if __name__=='__main__':
import plac
plac.call(plac.commands(cmd1, cmd2))
This should then produce usage info like this
$ basescript --help
usage: basescript [-h] command
...
commands:
cmd1
cmd2
$ basescript cmd1 --help
usage basescript cmd1 [cmd1 specific options]
...
$ basescript cmd2 --help
usage basescript cmd2 [cmd2 specific options]
...
Maybe one could even extend to subcommands and so on.
Maybe this is already possible but just not covered by the first link
I've read by now.
Anyway, I very much like this package and it seems like I have a new
friend at my disposal.
Thanks and best regards
Andre
More information about the Python-list
mailing list