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 support for help option #301
Comments
+1 |
1 similar comment
👍 |
+1 |
Still open after 3+ years? Anyhow commander can be extended using |
This has gathered a few likes over the years, so not closing quite yet. I have some problems with choosing colors:
I suspect it is too much trouble to build in directly, but perhaps commander can make it easier for people to customise the help output. |
This issue has not had any activity in over six months (other than a comment suggesting it be closed). It isn't likely to get acted on due to this report. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
Sywac isn't well documented, but it has a way to specify colors like this: // See http://sywac.io
const cli = require('sywac')
cli
.string('-c, --cloudEnv <env>', {
description: `The cloud env to use.`,
required: true,
})
.version('-v, --version')
.help('-h, --help')
.showHelpByDefault()
// Add colors to the help output!
.style({
usagePrefix: str => chalk().yellow(str.slice(0, 6)) + ' ' + chalk().bold(str.slice(7)),
usageCommandPlaceholder: str => chalk().bold(str),
usagePositionals: str => chalk().bold(str),
usageArgsPlaceholder: str => chalk().bold(str),
usageOptionsPlaceholder: str => chalk().bold(str),
group: str => chalk().yellow(str),
flags: str => chalk().bold(str),
desc: str => chalk().cyan(str),
hints: str => chalk().gray.dim(str),
groupError: str => chalk().red.bold(str),
flagsError: str => chalk().red.bold(str),
descError: str => chalk().red.bold(str),
hintsError: str => chalk().red(str),
messages: str => chalk().red.bold(str), // these are error messages
})
.parseAndExit()
.then(main)
.catch(e => {
console.error(e)
process.exit(1)
})
let c
function chalk() {
// lazily load chalk, only used if help text displayed
if (!c) c = require('chalk')
return c
}
async function main(opts) {
const {cloudEnv} = opts
console.log(cloudEnv)
} Example output with color: It'd be neat to have some sort of color configurability for Commander. |
It would still be nice to have a more simple api to change colors & styles |
#1365 is a major refactor of how the help is generated including user customisation, but not specifically about adding color support. |
No description provided.
The text was updated successfully, but these errors were encountered: