plac 0.5 is out!

M

Michele Simionato

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.

Now plac is much more than a simple command-line arguments parser: it
is
also a generic tool to write command languages, similar to the cmd
module in the standard library, only better. In particular plac
supports
a doctests-like functionality for each language you define for it,
as well as a plac runner to run your scripts and tests.

You define plac commands from Python functions: plac will build
a parser from the function signature and interpret the command line
accordingly.

The documentation contains a lot of simple and not so simple examples:

http://micheles.googlecode.com/hg/plac/doc/plac.html
http://micheles.googlecode.com/hg/plac/doc/plac_ext.html

Plac works in all versions of Python starting from Python 2.3 up to
Python 3.1, but the new features require Python 2.5.

You can download it from PyPI ($ easy_install -U plac):

http://pypi.python.org/pypi/plac

Enjoy!

Michele Simionato
 
A

Andre Alexander Bell

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.

How about adding some support for internationalization of the generated
usage output?


Andre
 
M

Michele Simionato

How about adding some support for internationalization of the generated
usage output?

The usage message of plac is actually generated by the underlying
argparse library. argparse use gettext internally, so I would say the
support is already there.
 
A

Andre Alexander Bell

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...

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
 
M

Michele Simionato

But this one is broken. :(

Aagh! The good one is http://micheles.googlecode.com/hg/plac/doc/plac_adv.html.
Luckily the one I posted on PyPI is correct.
<snip>
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.

Indeed this is already possible and covered in the advanced document.
See the section containers of commands:

http://micheles.googlecode.com/hg/plac/doc/plac_adv.html#containers-of-commands
 
A

Andre Alexander Bell

Aagh! The good one is http://micheles.googlecode.com/hg/plac/doc/plac_adv.html.
Luckily the one I posted on PyPI is correct.

Oh. Sorry, I was too lazy to search on PyPI. I just recognized the link
was broken and the link to the advanced document within the basic
document was broken too. So I did not search around.
Indeed this is already possible and covered in the advanced document.
See the section containers of commands:

http://micheles.googlecode.com/hg/plac/doc/plac_adv.html#containers-of-commands

Great. :) I'll read it...


Andre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top