eightshift-libs icon indicating copy to clipboard operation
eightshift-libs copied to clipboard

Running boilerplate commands doesn't recognize the context

Open dingo-d opened this issue 2 years ago • 3 comments

Describe your feature request

When running some CLI methods, I encountered two issues:

  1. If you have a theme installed alongside the plugin, for instance, and you run some CLI command in the plugin, the command will get executed in the theme (service class or some creation method), instead of a plugin
  2. When running some CLI commands (like main creation), you'll end up with a theme specific class, instead of plugin one:

https://github.com/infinum/eightshift-libs/blob/3c11801fcb67d29679c4d3e598565af1166e1894/src/Main/MainExample.php#L38-L41

(should be plugins_loaded hook).

Describe the solution you'd like

The CLI commands should be aware of their context - where to create certain commands, or some parts of the example should be changed.

Also, noticed a lot of 'theme' strings in the CLI methods, which then looks odd if you use it in the plugin (and have to change this).

These should probably be modified using a placeholder that can be interchanged to theme/plugin.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in this repo.

Yes

Please confirm that you have searched in our documentation and couldn't find the answer.

Yes

dingo-d avatar Jan 02 '23 12:01 dingo-d

The CLI commands should be aware of their context - where to create certain commands, or some parts of the example should be changed.

In what way should they be aware? Looking at the pwd? I recall that somewhere in the docs it was said to change the boilerplate command prefix in the plugin to accomplish that, I guess the reasoning is that you need to know "which" Libs registered the command 🤷

mbmjertan avatar Jan 03 '23 09:01 mbmjertan

Yes, we talked about this. You need to change the prefix for the commands. I will add some kind of description in the setup process

iruzevic avatar Jan 03 '23 09:01 iruzevic

The first part can be solved by changing the command name, the second part is still lacking. We could add a flag that will be used to distinguish between the theme and plugin maybe, and based on that search/replace certain strings and some files for the correct hooks, etc.

dingo-d avatar Jan 04 '23 14:01 dingo-d

this is done in the latest release

iruzevic avatar Jun 05 '24 11:06 iruzevic