Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running boilerplate commands doesn't recognize the context #351

Open
dingo-d opened this issue Jan 2, 2023 · 3 comments
Open

Running boilerplate commands doesn't recognize the context #351

dingo-d opened this issue Jan 2, 2023 · 3 comments
Assignees
Labels
feature request New feature request improvement Small improvement fixes, either readability or performance improvements wpcli Issues regarding WP-CLI

Comments

@dingo-d
Copy link
Collaborator

dingo-d commented Jan 2, 2023

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:

public function register(): void
{
\add_action('after_setup_theme', [$this, 'registerServices']);
}

(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 dingo-d added the feature request New feature request label Jan 2, 2023
@mbmjertan
Copy link
Collaborator

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 🤷

@iruzevic
Copy link
Member

iruzevic commented Jan 3, 2023

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

@dingo-d
Copy link
Collaborator Author

dingo-d commented Jan 4, 2023

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.

@iruzevic iruzevic added improvement Small improvement fixes, either readability or performance improvements wpcli Issues regarding WP-CLI labels Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature request improvement Small improvement fixes, either readability or performance improvements wpcli Issues regarding WP-CLI
Projects
None yet
Development

No branches or pull requests

3 participants