This patch adds support for --yes, --no, --pipe and --backend to drush_choice and drush_print_file. Not too common, but important for consistency.

Comments

greg.1.anderson’s picture

Status: Active » Needs review
moshe weitzman’s picture

Found a missing word or typo " but in backend and modes we will return the first option. "

i had not thought of using topic via --backend but thats perfectly reasonable. I wonder if drush_choice should return the list of choices instead of picking the first choice. That might be more handy when you don't know the list of topics that are available.

greg.1.anderson’s picture

Assigned: Unassigned » greg.1.anderson
Status: Needs review » Needs work

I started this so that topics could be viewed with --pipe to subvert the 'less' behavior, and put in --backend for consistency. Having drush_choice print the options in --backend mode is a good idea, particularly if coupled with a global --choice option to be able to select an item on the second pass.

greg.1.anderson’s picture

Status: Needs work » Needs review
StatusFileSize
new3.86 KB

Now it works as it should. --choice can be either numeric, or one of the symbolic identifiers from $options. --backend just prints the list of selections and exist; --pipe prints only the array keys (symbolic identifiers) from $options.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Typo persists: "// but in backend and modes we will return the first option."

I think --choice belongs in the new !$brief branch of global_options()

Otherwise, looks good.

greg.1.anderson’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

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