first sorry for my bad terminology, I am an electrical engineer, so maybe my coding terms are not so accurate or even far from that.
we have a CLI in the company, accessed from the Linux terminal, you know usual stuff, `{command.exe} {plugin} {options}, and you get the output on the terminal screen.
In order to unit test the product, we need it in a python class, which is returned as an object to the test environment, and eventually, prints that open a process that execute that command.
to build the command, we have a dictionary of the plugin, the subplugin, and the option for each cmd:
self.commands = {
"plugin": ['subplugin', 'subsubplugin', '-a', 'flaga', '-b', 'flagb'],...
and we built a function for every command we want, from the plugin
list extracted from the dict above
I am looking for a better approach that auto-built the tool entirely, sort of what the OS does for prediction.
I am assuming that would include the "set_attr" method of classes and stuff like that.
at the end of all this, I expect to access the plugin like this: cli.plugin.subplugin.subsubplugin(arg,arg,arg)
and that would generate a command cli, or at least the list above so I could inject it into the existing infra.
can anyone help, please?
thx in advance
I am more looking for guidence then say what I tried and fix it.
1条答案
按热度按时间oxf4rvwz1#
我找到了我的答案,这个代码对我很有效,你实现了我想要的。谢谢评论者。