-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 color for --help when output a tty #377
Conversation
Travis CI testing fails because the added packages are not vendored. Could you guys help me out with this? All the actual tests pass fine. |
@dborzov I'll try vendoring it later tonight/tomorrow. but if you get at it before me, you should be able to:
It sounds like you did all this already, but ran into problems. can you post any errors you got here? Thanks |
@chriscool tnx!
so apparently it attempts to look up the original vendored packages locally for some reason and freaks out when it does not find them. I guess you guys have them installed already so you don't see this. |
OK, so the fix i found was running |
Yeah, you may want to |
@chriscool yeah, |
@dborzov good to know, thanks! |
to help out with concerns like this one: #377 (comment)
Maybe we should put Thoughts @maybebtc ? |
"USAGE": c.DefaultColors["light_yellow"], | ||
"ARGUSAGE": c.DefaultColors["light_cyan"], | ||
"ARGUSAGETEXT": c.DefaultColors["light_red"], | ||
"DESCRIPTION": c.DefaultColors["white"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not everyone uses white on black. this should be c.DefaultColors["default"]
i think.
And these colors should be configurable in the config probably. (can get to that later)
Also, while some people like color (i do, sometimes), others don't. This should definitely be configurable. And possibly defaulted to off. |
We group templates and all the string variables separately and update the color tags in the init depending on if the output is a terminal
TerminalColors flag is to turn on and off coloring for terminal output. TerminalColors does not quite fit into the existing config subgroups, so I added Config.Preferences struct. The idea is to keep all the local appearance and formatting prefences there, whether it is for terminal output or WebUI.
Hey hey! So I made the suggested changes. I added the config flag for Terminal Colors: I ended up creating a new config subgroup for stuff like this: it is called Preferences. The idea is that all the local formatting and appearance-related settings can go there: stuff like the interface language, WebUI preferences and so on. I moved I am having a hard time reading off that flag's value when calling the help function, can anyone point me at what to call? |
func ShortHelp(rootName string, root *cmds.Command, path []string, out io.Writer) error { | ||
func ShortHelp(rootName string, root *cmds.Command, req cmds.Request, path []string, out io.Writer) error { | ||
terminalColors := false | ||
if req != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to read off the config's flag from here? I thought it has to be:
ctx := invoc.req.Context()
cfg, _ := ctx.GetConfig()
// we get cfg.Preferences.TerminalColors
but invoc.req
is not even initialized by default.
@jbenet, plz CR :) |
@dborzov sorry for the delay-- i havent had much time to CR code right now-- in particular tricky places like this part (main is really tricky :/ ). I'll try to get to this in the next few days. |
closing due to inactivity, please reopen as necessary note: all pull requests older than three weeks may be closed in an effort to keep our open pull requests more focused. |
IPFS's
--help
output now gets Chrismas lights when the output is on the terminal!See #340
Color rendering is only when stdoutput is on the terminal.
This uses
github.com/mattn/go-isatty
for checking if the output is on a terminalhttps://github.com/mitchellh/colorstring
for color coding stringsI was not able to add these packages to Godep. It probably should be
make vendor
orgodep save -r ./...
but these don't do the trick. What is up with that?Here is what it looks like for the standard Ubuntu color scheme: