consolidation / annotated-command

Create Symfony Console commands from annotated command class methods.
Other
221 stars 37 forks source link

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

Open weitzman opened 8 years ago

weitzman commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

sgurlt commented 5 years ago

This indeed would be a create feature! In addition to the proposal: https://github.com/consolidation/annotated-command/issues/53#issuecomment-252643688

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

greg-1-anderson commented 5 years ago

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 commented 3 years ago

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.