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

Use the allowed values list for options and arguments in hook_interact #53

Open
weitzman opened this issue Oct 10, 2016 · 6 comments
Open

Comments

@weitzman
Copy link
Member

Would be handy if the list if allowed values could be given in an annotation for options and arguments. See \Drush\CommandFiles\core\ViewsCommands::vlist (status option), for example.

@weitzman weitzman changed the title Allowed values array for options and arguments Allowed values list for options and arguments Oct 10, 2016
@weitzman
Copy link
Member Author

I'm envisioning @allowed-values argument/option-name [value1|value2|...]. For example

@allowed-values status enabled|disabled

I cant find any standard for delimiting multiple values beside pipe which is often used in the value of @return annotation.

@weitzman
Copy link
Member Author

weitzman commented Oct 14, 2016

Or we could optionally turn options/params into an array like field-labels. So,

@option status Filter Views to a given status. Allowed values are enabled, disabled.
  hidden: true
  allowed-values: enabled,disabled

@weitzman
Copy link
Member Author

weitzman commented Oct 15, 2016

FYI, I implemented @hidden-option annotation in \Drush\CommandFiles\core\DrupliconCommands and twice in the annotation_adapter.inc

@sgurlt
Copy link

sgurlt commented Apr 5, 2019

This indeed would be a create feature!
In addition to the proposal: #53 (comment)

it would be very useful to be able to specify a callback that could return options.

@greg-1-anderson
Copy link
Member

The other thing that is related to this is that Symfony Console has a paradigm for using the "interact" method, or @hook interact in annotated command, to allow tools to prompt for input to fill in values for required options that were not provided on the command line.

If an option can only take one of a set of predefined options, it would make sense for the tool to give the user a multi-select menu in hook interact to let them easily fill in this value.

If there was a way to stipulate what the allowed values were, it might also make sense to have an annotation that indicated that the value should be prompted for, and just do it for the user.

@weitzman
Copy link
Member Author

weitzman commented Sep 8, 2021

The new attributes feature has started using https://blog.jetbrains.com/phpstorm/2020/10/phpstorm-2020-3-eap-4/#expectedvalues in #223. Leaving open for the interact idea.

@weitzman weitzman changed the title Allowed values list for options and arguments Use the allowed values list for options and arguments in hook_interact Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants