Skip to content

No field labels - #130

Closed
greg-1-anderson wants to merge 5 commits into
drush-ops:masterfrom
greg-1-anderson:no-field-labels
Closed

greg-1-anderson wants to merge 5 commits into
drush-ops:masterfrom
greg-1-anderson:no-field-labels

Conversation

@greg-1-anderson

Copy link
Copy Markdown
Member

A user may want to see just the command output data, without any extra field labels; it should therefore be possible to tell Drush to omit the field labels.

Example:

$ drush status 'Drush configuration'
 Drush configuration   :  /home/ga/local/config/drushrc.php /home/ga/.drush/drushrc.php 

$ drush status 'Drush configuration' --no-field-labels
 /home/ga/local/config/drushrc.php /home/ga/.drush/drushrc.php 

The --no-field-labels version could more easily be processed in a bash for loop, for example.

…m command output if they do not want them (e.g. to emit only a single data item with --field=xyzzy --no-field-labels).
@yched

yched commented Sep 19, 2013

Copy link
Copy Markdown

This works currently (or at least worked until very recently, my local install is hosed right now)
drush st drupal_root --format=list

@greg-1-anderson

Copy link
Copy Markdown
Member Author

It would be interesting to go back in time and see where that worked. It seems like a good solution from a UX point of view. The reason it isn't working now is that --format=key-value (the default for Drush status) will flatten array values into strings (separated by spaces), whereas --format=list does not do this. Maybe these formats could be unified.

@yched

yched commented Sep 19, 2013

Copy link
Copy Markdown

sorry, I was not clear
drush st drupal_root --format=list does work atm (master drush branch)
It's just that drush has troubles with D8 right now so I was not sure it still worked as of today. But works on a D7 site.

Comment thread commands/core/outputformat.drush.inc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Show values without labels. For example, omits table headers, CSV headers, and labels in lists.".

Perhaps add an Example to a command that key-value and another to one that uses table.

@weitzman

Copy link
Copy Markdown
Member

Looks good.

  • Needs handling for CSV?
  • I'm not too fond of negative option names. How about --field-labls=0, which matches how we handle --strict

@greg-1-anderson

Copy link
Copy Markdown
Member Author

--format=csv does not print field labels, so it does not need to support a field label control option.

I can add the suggested documentation, and I'm fine with renaming this to --field-labels. However, one question about that: what about non-zero values for this option? Should it be possible to use --field-labels to control the labeling of output fields? I'm uncertain of the utility of this, but --field-labels sounds like it is more than just a binary option, and some might expect to be able to use it for something else.

I can see putting 'field-labels' => 'root=MyDrupalSite Root' in your site alias records to have enhanced labeling of drush @site1,@site2 status (and maybe even drush @sites status). Not sure how much this would be used.

Maybe it's okay to move forward with --field-labels as just a binary option for now.

@weitzman

Copy link
Copy Markdown
Member

IMO, CSV should be printing field labels like tables do ... Yes, I was thinking a boolean option, just like --strict.

@greg-1-anderson

Copy link
Copy Markdown
Member Author

--field-labels is now handled as a boolean option, defaulting to on, and csv prints field labels like tables do.

The above commits introduce a regression: drush core-status 'drush version' --format=list no longer works. Looking into that now.

@greg-1-anderson

Copy link
Copy Markdown
Member Author

All tests are passing now; I think it would be good to get this into 6.1.0, if possible.

Strictly speaking, adding field labels to CSV is a behavior change; however, no core Drush commands use csv as the default format, so perhaps the exposure here is low enough to be considered negligible. If it's a concern, then omit edf4d81 and 69220f4 from Drush 6; however, I think I'd rather see Drush 6 and Drush 7 behave consistently here.

@weitzman

Copy link
Copy Markdown
Member

I'm also OK with that behavior change for 6.x.

I rebased and squashed the commits onto master. That made sense to me as there was some back and forth about --no-field-labels in the commit history, that I didn't think we needed to preserve.

There is a small conflict when cherry-pick onto 6.x. I would appreciate if @greg-1-anderson could resolve and push. Thanks.

@greg-1-anderson

Copy link
Copy Markdown
Member Author

Resolved and pushed to 6.x.

@weitzman

Copy link
Copy Markdown
Member

I'm not seeing field labels for CSV. I tried:
dr pml --format=csv --field-labels=1
dr pm-updatestatus --format=csv --field-labels=1

@weitzman

Copy link
Copy Markdown
Member

This is now possible in master branch. See #2460

@weitzman weitzman closed this Nov 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants