Any command in Drush core that uses drush_print_pipe should instead implement Drush output format engines. Examples exist in archive.drush.inc, field.drush.inc, help.drush.inc, pm.drush.inc, updatecode.pm.inc, make.drush.inc, sitealias.drush.inc, user.drush.inc, role.drush.inc, search.drush.inc, queue.drush.inc and variable.drush.inc.
The contrib modules drush_iq and devel also use drush_print_pipe; however, these probably should not be updated until Drush-6 stable is released.
Resolution on #1912616: Simplify the declaration of engine data in commands. is a prerequisite for this issue.
Comments
Comment #1
moshe weitzman commented#1912616: Simplify the declaration of engine data in commands. has been committed so this issue can now proceed. Help wanted.
Comment #2
greg.1.anderson commentedMost commands should be pretty easy to do. I think I'll likely do some work on this on Saturday. I'll be away from the internet at the time, so anyone who wants to help out is encouraged to post here in advance.
Comment #3
greg.1.anderson commentedHere is a patch for sql.drush.inc. Only sql-conf is applicable command here. Note that even with the addition of a new output feature to support --show-passwords, commands are pretty easy to convert to the new output mechanism.
More commandfiles coming.
Comment #4
moshe weitzman commentedLooks good. Patch is RTBC. ... For straightforward conversions like this, you are welcome to commit directly, without discussion. Interested parties can read the commit log.
Comment #5
greg.1.anderson commentedCommitted #3; will continue to commit commandfiles as they are ready. Will update this issue periodically and mark 'fixed' when done.
Comment #6
greg.1.anderson commentedI have several more conversions in progress. I am planning on putting these in as individual commits to allow folks to individually diff the things that go with each commandfile, and for isolation purposes, in case something is discovered to be broken later. This is what my local git log looks like right now:
A progress patch is attached for the curious. I am holding off on committing this because there are some problems with supporting --fields with certain list types. Once I have this worked out and the tests are passing again, I will commit.
Advice: If you are working on converting a command that should support --fields, and you want to use some output format other than table or key-value, you might want to hold off until this patch lands.
Comment #7
greg.1.anderson commentedMade a whole slew of outputformat commits:
f900dcb: Issue #1912628 (part 9): Add csv-list output format and clean up output from various commands from parts 2-8 to make tests pass again.
515873e: role-list
252932c: field-info
dfd30d5: search-status
c734cb9: variable-get
dab13d9: queue-list
f0b5f43: pm-info (improved version included in initial commit)
df11c1f: user-list
Comment #8
greg.1.anderson commentedStill to do:
pm-updatecode: Will need to split out a new hidden command, pm-updatestatus, that prints the update status table that appears prior to the confirmation prompt in pm-updatecode.
pm-list: Very similar to pm-info. Has options to filter the output based on field values.
site-alias: The default output format for site-alias currently varies when called with no arguments. Engine mechanism will need a small enhancement to allow the selected engine to be dynamically changed in a command's implementation.
cache-get: currently handles --format in its own code
variable-get
watchdog-list
watchdog-show
config-get
config-list
Not planning on doing in this issue:
help: Uses drush_print_pipe to display a list of command names. The non-pipe output is not well suited for formatting.
archive-dump: Uses drush_print_pipe to display the name of the archive created.
make: Uses drush_print_pipe only when called with the --version option.
pm-download: Uses drush_print_pipe to display the list of modules in each project downloaded.
These last I figure can stay as they are until drush_print_pipe is removed completely from the code base.
Comment #9
greg.1.anderson commentedThree more commits on output format engine work:
ea59f98 Issue #1912628 (part 12): refine output of variable-get
edcd8bf Issue #1912628 (part 11): support named fields in site-alias output
5afcedd Issue #1912628 (part 10): convert site-alias to use outputformat engine
Comment #10
greg.1.anderson commented7de5a6b Issue #1912628 (part 13): convert watchdog-show and watchdog-list to use outputformat engine
Comment #11
greg.1.anderson commentedbeef489 Issue #1912628 (part 14): convert cache-get to use outputformat engine
Comment #12
greg.1.anderson commented4bf0743 Issue #1912628 (part 15): convert pm-list to use outputformat engine
Comment #13
greg.1.anderson commented9c4ef70 Issue #1912628 (part 17): Factor pm-updatestatus command out of pm-updatecode and convert it to use outputformat engine.
2842b1e Issue #1912628 (part 16): Remap fields id to #id and name to #name so that we do not need to alter the alias data prior to output, which might be confusing.
Comment #14
greg.1.anderson commented447f903 Issue #1912628 (part 18): convert config-get and config-list to use outputformat engine. Add 'yaml' (Drupal-8 only) and 'php' (serialized) output formats.
Note that the 'yaml' output format engine added by this commit was ported from config-get, and has the same limitation as the original code: it currently only works when a Drupal 8 site is bootstrapped. This is fine for config-get, which only works in a D8 environment, but is limiting in most other situations when the yaml format might be desired. Continuation is at #1366098: Automatically download Symfony YAML component.
Comment #15
greg.1.anderson commentedAll Drush core commands that should support output format engines now use them. There is still some continuation work to be done here on a few commands that do not support output format engines as well as they should. For example:
- drush status: Needs to support field labels
- drush core-requirements --pipe: Changed format. Should switch back to former format for consistency
Also, some commands list some output formats in their help that do not actually produce useful output. It would be helpful if we could further refine format selection, so these are not shown.
I will continue to commit straightforward refinements on this issue, but expect to finish up and mark this 'fixed' shortly.
Comment #16
greg.1.anderson commented7af2748 Issue #1912628 (part 19): support user-selectable fields in Drush status.
Comment #17
moshe weitzman commentedSounds like there is little left to do here. Thanks!