Welcome to xcmds’s documentation!

class xcmds.xcmds.xcmds(callable_dict: dict, exclude: list = None, include: list = None, log=True)[source]

Translate functions into commands

Parameters
  • callable_dict – a dict, {‘function name’: ‘function_object’, …}.Usually it is result of locals()

  • exclude – a list, do not translate functions in it

  • include – a list, only translate functions in it

  • log – if save command line into a log file

description2dict(description)[source]

this will only work with doc string in pycharm style :param description: docstring :return:

Example

content of example.py:

from xcmds.xcmds import xcmds
from pprint import pprint as print


def func(a=1, b=2):
    print(a*b)


def func2(a='x', b=3):
    print([a]*b)


if __name__ == '__main__':
    xcmds(locals(), exclude=['print'])

Now functions in example.py are ready be called with commandline, such as:

python example.py func -a 2 -b 3

Indices and tables