Usage of Commanger


Pip is the best way to install Commanger, you can do it with the command below

pip install commanger

but if you don’t want to you can install is here on pypi.


Once you install commanger the next step is preparing the file with basic code:

from commanger import commanger
cmd = commanger("cmd")


commanger should only be called once per process

As shown above you need to import the class then init it with commanger(name), name is not yet used. Now lets get started!

Basic Example: Continued

We start where we left off:
cmd.basicCfig([1,2,"b"]) #set a basic config

@cmd.command #Attach the main func
def main(args): #Take in the args

Now lets change the config a bit:



Nums in the basic config are positional arguments and strings are toggle arguments.

Now we should have a config with 2 positional arguments and 2 toggles, one named “b” and the other named “c”

Lets call it now with:

python hello world

With your current code you should get this result:

{"1": "hello", "2": "world", "b": False, "c": False}

If you run this: python hello world -b, you get:

{"1": "hello", "2": "world", "b": True, "c": False}

And if you run this: python helloworld, you should get the error:

commanger.commanger.ArgumentError: Arg number 2 not in ["","helloworld"]

You can do what you want with the args in the main function, it’s up to you. Thats it for basic usage!


In the future I will add more tools to help you manage arguments

Function Tool usage

commanger.ppconfig(self, config=None)

Returns a pretty version of your config so you can easily edit you config. If you have a seprate config then provide it.



commanger.eval(self, args)

The arg content parser. Input of: "(hi,hello,1)" would be parsed to ('hi','hello',1) (python formated and typed.)

commanger.commandU(self, funct)

Gives args to the main function as kwargs. you can handle them like this:

def main(*,h,hi,j,jk): #keyword arguments are defined with a *