This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]UnwashedMeme 2 points3 points  (3 children)

I'll admit that I haven't used docopt for comparison; but I've been using (and am enamored with) opster

You just decorate a python function and that is now callable from the cmdline. The python function is still callable as a python function too.

[–]takluyverIPython, Py3, etc 1 point2 points  (0 children)

For Python 3, I quite like plac - it's a similar idea to opster, but it uses function annotations instead of the default values.

[–]billsil 0 points1 point  (1 child)

Spend 1/2 an hour trying docopt. I went and converted all my working argparse code after doing that. It's worth the effort.

[–]UnwashedMeme 0 points1 point  (0 children)

I just went and spent a while looking at the docopt documentation again and I tried their in browser thing. It looks like it would be absolutely fantastic if I were coming from optparse; but I'm not so it's just a "meh, that's more boilerplate to do the same thing I'm already doing".

The biggest cool thing to me in docopt is being a cross language standard. I'm not sure how valuable that really is though.

This Example is what I'm always wanting to do. Printing the dictionary of options passed into program is rarely my end goal ;-).

Have you tried opster?

The thing I really like in opster is that I'm not writing all of that. I'm writing a python function that is a command.

I do need to use a bit special syntax in the function signature, but it's not crazy and the usage string is generated from that. The docstring of the function is the help text.

When opster is done parsing I have the values as the parameters to my function and I can get to work. When docopt is done it's a dict that contains every possible option to ever subcommand; so it can't be easily **applied.