Problem:

1) When adding a variable to db via drush, you get prompted as to whether to create a new variable
2) --yes option does not work in the case where the new variable has the same beginning of another variable.

Example, on a new site:

a) run "drush --yes vset site_offline 1" on the command line
b) you get the following choices:

0) Cancel
1) site_offline (new variable)
2) site_offline_message

c) in this case --yes has no effect. The user still gets prompted. This is bad when drush runs within a script because it causes the script to halt.

Attached is a patch for this edge case which creates a new --force option to be used with vset.

Comments

greg.1.anderson’s picture

Status: Active » Needs review
StatusFileSize
new3.62 KB

Beautiful. Works just the way I would want it to.

I did make a couple of minor adjustments. I removed '-f' as a synonym for '--force'; you must use '--force'. I was worried that introducing a new global '-f' might conflict with existing drush commands. I also made '--force' imply '--yes'.

Seems to be working nicely now, but since this touches a global option, it should have another set of eyes on it before going in.

greg.1.anderson’s picture

Assigned: Steve Dondley » Unassigned
moshe weitzman’s picture

Status: Needs review » Needs work

I'd just as soon make this a local option for vset and not a global option. Lets add to global when more needs arise. Also, lets add an example to vset that uses this.

Steve Dondley’s picture

Greg, can you please handle Moshe's suggestion to make it a local option for vset? I'm not very familiar with the module. Thanks.

greg.1.anderson’s picture

Assigned: Unassigned » greg.1.anderson

Yes, I'll take this; no problem.

greg.1.anderson’s picture

StatusFileSize
new1.6 KB

Here you go. I used '--always-set' instead of '--force' so that a user could set this in their drushrc file if they wanted to stipulate this should be the default behavior.

greg.1.anderson’s picture

Status: Needs work » Needs review
greg.1.anderson’s picture

I need this at work; is it okay to commit it?

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

sure, go ahead.

greg.1.anderson’s picture

Status: Reviewed & tested by the community » Fixed

Committed; thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.