2

My custom Drush commands use options(--ver,--env,etc). Whenever the option is used, I get message:

Unknown option: --ver.  See `drush help build-asset` for available options. To suppress this error, add the option --strict=0.

By adding --strict=0, it will suppress the message, however. how to make the custom Drush commands run with --strict=0 automatically or what needs to be done to avoid this all together. Thank you for helping

3

The fact that Drush is telling you that the options you are using on the commandline are not supported by your command is a feature. This protects you from having the wrong thing happen if you mistype an option name; it is not a good idea to subvert this feature, because that leaves you open to confusion when you do make a typo.

To declare which options your command uses, define the 'options' element, and list all of the options that are applicable for your command. For instructions, see drush topic docs-examplecommand.

For your command, your options should look something like this:

'options' => array(
  'ver' => array(
    'description' => 'Specify a version number.',
  ),
  'env' => array(
    'description' => 'Describe your environment.',
  ),
),

You might find the drushify command to be useful in starting you off when creating a Drush commandfile. It will make a nice template for your command that you can edit to suit; the command options is one thing that is roughed in for you. Just delete the parts of the generated code that you don't need, fill in your implementation and command help, and you're good to go.

  • Thank You Greg. I was defining options, however. It was done in the wrong way(i guess i am using older version of your book). I was defining options with '--' in front, but it needs to be as Greg demonstrates in the sample above without '--' in front. Thank you. Problem solved – latvian Sep 7 '14 at 16:28
  • Thank you for the awesome guide/book on Drush by the way:) drush.org/sites/default/files/attachments/DGD7-Drush.pdf – latvian Sep 7 '14 at 16:33
  • I guess the '--' went away in Drush 5. Guess I better update the guide! – greg_1_anderson Sep 7 '14 at 17:37
  • I did update this page just now: drush.org/drush-4-to-drush-5 – greg_1_anderson Sep 7 '14 at 17:47
  • Thanks for this answer. It is nice to know why this error message was actually being shown. – rineez Oct 2 '14 at 14:04
3

There's enough situations where I need to do that that I have just defined an alias in my startup file.

alias drush='drush --strict=0'

This is in my .zshrc file (or put in your .bashrc file if using bash).

  • Thank you cleaver. It would work,however. This is a tool i like to transfer across multiple servers and environments including production to help deploy,etc....it would be much of inconvenience to setup alias every time. Any alternative solution within Drush itself? – latvian Sep 7 '14 at 2:53
  • There is the drushrc.php file as well... You could presumably do $options['strict'] = 0 there. See: drush.ws/examples/example.drushrc.php – cleaver Sep 11 '14 at 14:58

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.