Question

I have one ruby app and one plugin. Each, within their own workspaces, have some console commands independent of the other. I wanted to use the commands of the plugin by somehow instantiating the plugin within the original app's workspace. The following example explains my requirements. Some guidance on how to achieve this would be appreciated.

cd main_app
main_app -h
The following are main_app commands:
-a      # does apple for main app
-b      # does basket for main app
-set_ws # sets/ enables the work space of specified plugin (need to implement this).
cd ../plugin_app
plugin_app -h
The following are plugin_app commands:
-c      # does cat for plugin_app
-d      # does dog for plugin_app

I would like to implement something of this sort:
cd main_app
main_app -set_ws plugin_app
main_app -h
The following are main_app commands:
-a      # does apple for main app
-b      # does basket for main app
-set_ws # sets/ enables the work space of specified plugin.
The following are plugin_app commands:
-c      # does cat for plugin_app
-d      # does dog for plugin_app
Was it helpful?

Solution

Since we don't know anything about your plugin, there is no way we can tell you how to integrate the two.

If the plugin was properly implemented to be integrated into another application, I guess you could instantiate some CLI class, or even instantiate a service class, and call the proper API.

The only coding I can suggest, given your input (and assuming the ruby app at least knows where the plugin is) - the ruby app can simply call the plugin CLI from a shell using Backticks:

if args == ['-c']
  `../plugin_app -c`
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top