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

Add isPiped() method to \cli\Table #11

Merged
merged 2 commits into from
Sep 15, 2012

Conversation

goldenapples
Copy link

Adds a method to \cli\Table to check whether output is being displayed
in terminal or is being piped to another command or redirect. If output
is being piped, table should be output as tab-separated text rather than
with ASCII borders.

This is the same output behavior that other unix commands such as mysql
use to determine whether to output a graphical table or tab-delimited text.

Adds a method to `\cli\Table` to check whether output is being displayed
in terminal or is being piped to another command or redirect. If output
is being piped, table should be output as tab-separated text rather than
with ASCII borders.
foreach ($this->_rows as $row) {
\cli\line($this->renderPipedRow($row));
}
exit;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should just return. We don't want to quit the entire application after rendering the table out, there could still be work that needs to be done.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, you're right... this could be called as part of another command. I'll fix this.

@jlogsdon
Copy link
Contributor

Excellent addition! One minor change and I'll merge it in. Thanks!

Since \cli\Table::display() will be called from another command, don't
assume that the script is done - there might still be work to do.
@goldenapples
Copy link
Author

This will be really cool, thanks for merging! I'll be using this as part of some commands in wp-cli: wp-cli/wp-cli#161

jlogsdon added a commit that referenced this pull request Sep 15, 2012
@jlogsdon jlogsdon merged commit 6bc4bfd into wp-cli:master Sep 15, 2012
@jlogsdon
Copy link
Contributor

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants