简体   繁体   English

通用python rpc和cli接口

[英]Common python rpc and cli interface

I have a cli app which uses argparse and would like to add an rpc interface with pyjsonrpc. 我有一个使用argparse的cli应用程序,想用pyjsonrpc添加一个rpc接口。

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? 有没有一种方法可以从另一个生成一个,或者有一个可以同时生成两个抽象的接口?

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. 我找不到合适的解决方案,所以我决定编写一个小的库,该库从基本定义类生成cli和rpc接口。

Once its refined I will add it to the pypi, currently its available at https://github.com/F483/apigen 精炼后,我将其添加到pypi中,当前可从https://github.com/F483/apigen获得

Edit: pypi package 'apigen' is now available https://pypi.python.org/pypi/apigen 编辑:pypi包'apigen'现在可用https://pypi.python.org/pypi/apigen

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM