jorgebucaran/colorette

Support `--color` and `--no-color` flags?

jorgebucaran opened this issue ยท 14 comments

We should probably support --color and --no-color flags in process.argv like chalk/supports-color does.

Also: webpack/webpack-cli#2966

cc @kibertoad @snitin315 @alexander-akait

Sounds good!

Nice to have :)

Hi there, my name is Andre Willomitzer and I am a student from Canada studying computer programming. Currently we are contributing to open source projects we are interested in. Recently, I built a command line tool for parsing TXT/MD files to html files.

Would you be interested in discussing me working on this issue? I think this can be done using Yargs another open source library. It allows the use of "alias" and "options" in the command line.

For example you could type --no-color, and then in the code check for whether argv.noColor exists (OR) if the "NO_COLOR" in env is true. Either way, you would disable colors in the terminal right?

If I am misunderstanding what the --color and --no-color is supposed to do please let me know.
All the best,
Andre

In this case, we just need to process.argv.includes(flag) for each flag. Or do you mean that Colorete consumers should take care of this on their own?

const colors = createColors({ 
  useColor: process.argv.includes("--color") && !process.argv.includes("--no-color") 
})

Either way, we don't really need to add a dependency.

@AndreWillomitzer Would be awesome if you could work on this!
However, colorette is a zero-dependency library and should stay so, so using yargs is not an option.

I think that --no-color should have more priority than --color, just like NO_COLOR has over FORCE_COLOR.

So, both of the following should produce no color.

FORCE_COLOR= awesome-cli --no-color
NO_COLOR= awesome-cli --color

Yep, agree

Available in 2.0.13. ๐Ÿˆโ€โฌ›

@jorgebucaran Readme needs to be updated.

Should be good now. Thank you, everyone! ๐Ÿ™Œ

Wow you guys fixed that so fast. And the idea about not adding libraries makes sense, I never considered that you want the fewest dependencies.

Is there any other issue you think a beginner like myself would be able to fix?

Thanks, that makes a ton of sense what you did with

const colors = createColors({
useColor: process.argv.includes("--color") && !process.argv.includes("--no-color")
})

Pretty sure issues will pop up sooner or later. If you decide to watch this repository, you'll find out when that happens, and perhaps you'll help us then. Thank you, Andre.

Okay! Thanks Jorge nice e-meeting you I'll watch the repo then.

Sad I didn't get to contribute a change though because this type of task seems perfect for learning haha.

All the best,

Andre

@AndreWillomitzer I'm going to shamelessly hijack the thread, but if you are looking for a not-too-complicated OSS task to do, I would be happy if you could take a look at kibertoad/toad-scheduler#24 :D