Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No field labels #130

Closed

Conversation

greg-1-anderson
Copy link
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
Copy link

yched commented Sep 19, 2013

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
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
Copy link

yched commented Sep 19, 2013

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.

@@ -64,6 +64,9 @@ function outputformat_drush_engine_type_info() {
'description' => 'In nested lists of lists, specify how the outer lists ("lines") should be separated.',
'hidden' => TRUE,
),
'no-field-labels' => array(
'description' => 'Leave off the field labels.',
Copy link
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
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
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
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
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
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
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
Member Author

Resolved and pushed to 6.x.

@weitzman
Copy link
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
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