My module will be run from the command line. The Drush command would be something like this:

drush create-denver-type --name="some title" --title="some title" --options="apple" --userid="myid"

--options can have one option or five. I'm using a switch statement and only passing one value through --options. What do I need to do to pass two or three values to --options, for example --options="apple, pear, orange"?

Basing on the values passed in --options, different functions will be called.

When gathering multiple values, how do I pass them to my function, and call the correct functions based on the value passed in --options?

$options = drush_get_option_list('options');

This will return something like array('apple') or array('apple','pear','orange').

Yeah, Drush does everything.

  • I don't know how to incorporate a foreach into the code so that it will determine what values are in the array and then run the needed function(s). I made an edit above to show show where I am stuck in my switch. – user1176783 Nov 20 '13 at 5:44
  • 1
    Now THAT question is out of scope for Drupal Stack Exchange. You could use a foreach / switch, or perhaps call_user_func to do what you'd like, but basic php questions should be asked elsewhere. – greg_1_anderson Nov 20 '13 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.