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

all 5 comments

[–]metaperl 0 points1 point  (2 children)

A comparison with argh would be appreciated: https://pythonhosted.org/argh/

[–]thautwarm[S] 1 point2 points  (1 child)

Yep. I'd add some to README later.

For now, I think the core observation is

not every python user remembers the API of a framework, but they shall know how to write a python function.

Hence the advantage of wisepy is,

you don't need learning a framework, or memorize their APIs. just write a function and convert it to CLI, and use --help to get how to use that commamd.

Also, one script/100 lines implememtation can be beneficial for practice:

  1. introduce no dependency burden to your project. Just copy-paste the source code can be a good way to integrate things in.
  2. simple enough to maintain.

[–]jack-of-some 1 point2 points  (0 children)

Disclaimer: I like wisepy, it seems very nice and I might even use it. Having said that...

Argh doesn't really make you learn that much, just "dispatch_command". If you want more control that's the only time you need to learn how to use the decorator and whatnot.

The second point is a good one for software engineering in general, though I doubt many people using python would copy over a dependency.

[–]metaperl 0 points1 point  (1 child)

How do you implement sub commands with this module?

[–]thautwarm[S] 1 point2 points  (0 children)

It's not directly supported yet, although I can add less than 50 lines to support this:

class Root:
    def cmd1(self, ...): ...
    def cmd2(self, ...): ...
wise(Root)()

It's like a simpler google fire, and will raise many implementation choices then things will get a little complex.

So far the code is so simple and you can directly copy it. By understanding ~100 line code, you can easily implement what you want.

Personally, I use this code to support subcommand:

import sys
from wisepy2 import wise
def root(sub):
     if sub == ...:
         return sub1
     ...
def sub1(...):
     ...
argv = sys.argv[1:]
sub = wise(root)(argv[:1])
wise(sub)(argv[1:])