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

InputOption::getDefault() not returning fields for drush status #6014

Closed
lkmorlan opened this issue May 28, 2024 · 3 comments
Closed

InputOption::getDefault() not returning fields for drush status #6014

lkmorlan opened this issue May 28, 2024 · 3 comments

Comments

@lkmorlan
Copy link

Describe the bug

I am trying to add information to drush status following the example ExampleStatusFieldHook.

To Reproduce
Created a command file following the pattern in ExampleStatusFieldHook.

Expected behavior

$options['fields']->getDefault() returns a comma-separated lists of the fields that appear by default when drush status is run.

Actual behavior

$options['fields']->getDefault() returns the empty string. As a result, when I set the default to ,example-status, it gives the error that there is no field named by the empty string (referring to the empty string before the comma). If I set the default to just example-status, then just that field appears instead of that field being added to what is normally output.

Workaround

I could hard-code the list of fields in my command. This would mean that I would have to update my command if the list ever changes.

System Configuration

Q A
Drush version? 12.5.2.0
Drupal version? 10.2.6
PHP version 8.2.9
OS? Linux

Additional information

The above only happens if I make it site-wide command. It does not work if I put the command in the module. In this case, @hook command-event core:status never gets triggered, so I must add --fields=* or --field=example-status to see the new information.

@weitzman
Copy link
Member

example-drush-extension has not kept up with Drush. I'm not sure its a reliable source anymore

@lkmorlan
Copy link
Author

OK. Is there any way of getting the list of fields that appears by default in drush status?

@weitzman
Copy link
Member

I think you want a command info alterer https://www.drush.org/12.x/commands/#altering-command-info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants