Search code examples
pythoncommand-line-interfacerpcargparse

Common python rpc and cli interface


I have a cli app which uses argparse and would like to add an rpc interface with pyjsonrpc.

It seems I will have to duplicate a lot of code and maintain two interfaces which I would rather not do.

Is there a way generate one from the other or have an abstract interface that generates both?


Solution

  • I couldn't find an adequate solution so I decided to write a small lib that generates the cli and rpc interface from a basic definition class.

    Once its refined I will add it to the pypi, currently its available at https://github.com/F483/apigen

    Edit: pypi package 'apigen' is now available https://pypi.python.org/pypi/apigen