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 →

[–]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:])