8000 escape sequences to pipe by k0kubun · Pull Request #13 · k0kubun/pp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

escape sequences to pipe #13

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

Merged
merged 3 commits into from
Mar 1, 2015
Merged

escape sequences to pipe #13

merged 3 commits into from
Mar 1, 2015

Conversation

k0kubun
Copy link
Owner
@k0kubun k0kubun commented Mar 1, 2015

pp write escape sequences into output stream. when the output is not a terminal, i wonder how pp should do work.

  • remove escape sequences?
  • same as terminal?

I'm thinking pp SHOULD NOT have behavior against whether stdout is terminal or not.
So, I want to you to provide A WAY to remove escape sequence for pp, but formatting is enabled.

How do you think?

@k0kubun
Copy link
Owner
k0kubun commented Feb 25, 2015

So, I want to you to provide A WAY to remove escape sequence for pp, but formatting is enabled.

It looks good. Sometimes you may want to log the pp's result to a text file. In that case, removing escape sequences will be convenient. Now I can think of 3 ways to achieve it.

  1. provide a variable or function to switch whether color output or not
  2. provide an API to print not-colored output (very convenient to use but this may add many APIs)
  3. provide io.Writer which removes escape sequences to use with pp.SetDefaultOutput (maybe it is not pp's responsibility?)

So I think 1 is good. But I'll accept any implementation if it is simple and easy to maintain.

@mattn
Copy link
Author
mattn commented Feb 25, 2015

So I think 1 is good. But I'll accept any implementation if it is simple and easy to maintain.

yes, it's not need to be intelligent. someone may want the escape sequence intended. We can set true/false using https://github.com/mattn/go-isatty

@k0kubun
Copy link
Owner
k0kubun commented Feb 25, 2015

I'm thinking pp SHOULD NOT have behavior against whether stdout is terminal or not.

Ah, I guess you mean that pp SHOULD NOT switch the behavior automatically but providing A WAY to switch it automatically is good?

yes, it's not need to be intelligent. someone may want the escape sequence intended. We can set true/false using https://github.com/mattn/go-isatty

That's a nice library to know. If you solve this issue with it, the implementation will be simple. :)

@mattn
Copy link
Author
mattn commented Feb 25, 2015

Not automatically. Just add flag :)

@k0kubun
Copy link
Owner
k0kubun commented Feb 25, 2015

I see. Anyway having such a flag would be good.

@k0kubun
Copy link
Owner
k0kubun commented Mar 1, 2015

@mattn I added pp.ColoringEnabled flag to switch coloring behavior. Is this ok for your use case?

Merging for now.

k0kubun added a commit that referenced this pull request Mar 1, 2015
@k0kubun k0kubun merged commit 7b20495 into master Mar 1, 2015
@k0kubun k0kubun deleted the coloring_switch branch March 1, 2015 12:15
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.

2 participants
0