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

scmpuff status: migrate hardcoded ANSI color codes to a cross-platform color library #28

Open
mroth opened this issue Apr 4, 2017 · 2 comments

Comments

@mroth
Copy link
Owner

mroth commented Apr 4, 2017

This will improve cross-platform support for future shells, and also hopefully allow the code to become more clean and understandable. As @stereokai showed in #14, currently Windows in PowerShell does not properly render the ANSI escape codes as color.

There is likely a strong chance to refactor and clean up the UI formatting code with this too, which is worth being opportunistic with if it presents itself.

Some of the color libraries seem to have the built in ability to disable color output entirely in a convenient way without branching all the UI code (fatih/color), which could be a nice command line switch to add to scmpuff status if easy enough to do cleanly.

@stereokai
Copy link

I actually used something really simple for the FPrint() methods: https://github.com/mattn/go-colorable

It only took changing from os.Stdout to NewColorableStdout() for example, and that made scmpuff status work in both CMD and Powershell.

@mrcljx
Copy link

mrcljx commented Oct 19, 2017

Maybe we could just use git's internals for this? Would allow configuration as well (we'd have to provide default colors though which we probably have to pull out of the git codebase):

git config --get-color color.status.added 'red'

From man:

       --get-colorbool name [stdout-is-tty]
           Find the color setting for name (e.g.  color.diff) and output "true" or "false".  stdout-is-tty should be either "true" or
           "false", and is taken into account when configuration says "auto". If stdout-is-tty is missing, then checks the standard
           output of the command itself, and exits with status 0 if color is to be used, or exits with status 1 otherwise. When the color
           setting for name is undefined, the command uses color.ui as fallback.

       --get-color name [default]
           List all variables set in config file, along with their values.

Would probably also fix #9

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

No branches or pull requests

3 participants