add option --color and do not show colors when the output is not a tty #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
Disable color display when the output is not a tty.
This change should not break the current workflow when tldr is used in terminals, but perhaps can break some CI runs (though unlikely), or perhaps someone's Emacs config that assumes color output. In that case, the users can pass
--color
to force color output to get the old behavior.Why the change?
For example, when I call in emacs
M-! RET tldr <cmd> RET
, the display is very unreadable.After the change:
See also #35.
How can this be tested?
tldr cmd > file
: no colortldr cmd
: has colortldr --color cmd > file
: has colortldr cmd | cat
: no colortldr --color cmd | cat
: has colorWhere to start code review?
getopt options, and
color_flag
Relevant tickets?
#35
Questions?
It is unclear whether to pass
color_flag
toprint_localpage
. For now, I simply passed 1 to preserve compatibility.