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

Support --color and --no-color flags? #77

Closed
jorgebucaran opened this issue Sep 25, 2021 · 14 comments
Closed

Support --color and --no-color flags? #77

jorgebucaran opened this issue Sep 25, 2021 · 14 comments
Labels
enhancement New feature or request

Comments

@jorgebucaran
Copy link
Owner

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

@jorgebucaran jorgebucaran added the enhancement New feature or request label Sep 25, 2021
@kibertoad
Copy link
Collaborator

Sounds good!

@snitin315
Copy link

Nice to have :)

@AndreWillomitzer
Copy link

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

@jorgebucaran
Copy link
Owner Author

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.

@kibertoad
Copy link
Collaborator

@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.

@jorgebucaran
Copy link
Owner Author

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

@alexander-akait
Copy link

Yep, agree

@jorgebucaran
Copy link
Owner Author

Available in 2.0.13. 🐈‍⬛

@kibertoad
Copy link
Collaborator

@jorgebucaran Readme needs to be updated.

@jorgebucaran
Copy link
Owner Author

Should be good now. Thank you, everyone! 🙌

@AndreWillomitzer
Copy link

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")
})

@jorgebucaran
Copy link
Owner Author

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.

@AndreWillomitzer
Copy link

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

@kibertoad
Copy link
Collaborator

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants