-
Notifications
You must be signed in to change notification settings - Fork 994
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
colors! #251
Comments
@fulmicoton Great suggestion! My opinion is that content decoration should be handled outside of Originally it only supported decoration via Please give Note 1: You'll probably want to focus on the Note 2: For best results (and full locale support), you should |
@fulmicoton I'm with @nexdrew on this, colors are a great extension to yargs but I think we should keep it out of core. Seem reasonable? |
Perhaps we could add a section to the README that has nifty related projects? |
I thought of that but didn't want to shamelessly advertise my module or make it seem like Personally I think it'd be cool to build support for plugins into |
Sorry for not replying earlier. Thank you so much @nexdrew for picking up on that so quickly. I will try that out later today. About the discussion of whether to put that in yargs or yargonaut, whatever works for you guys :) |
@nexdrew be as shameless as you see fit :) |
@nexdrew Thank you! It works fine for me. I wondered if it is possible to apply a specific color to option (-f, --file) and commands. |
@fulmicoton The official answer is no, because However, you can hack it via "hidden" commands and options, if you really want to. The code is pretty ugly, and you'll have to duplicate some var yargonaut = require('yargonaut')
var chalk = yargonaut.chalk() // could also just require('chalk') yourself
var argv = require('yargs')
.command(chalk.green('add'), 'Add a file')
.command('add', false, function (yargs) {
// need option validation here
console.log('adding')
})
.command(chalk.red('rm'), 'Remove a file')
.command('rm', false, function (yargs) {
// need option validation here
console.log('removing')
})
.demand(1)
.option(chalk.yellow('f'), {
alias: chalk.yellow('file'),
describe: 'The file to add or remove',
type: 'string'
})
.option('f', {
alias: 'file',
type: 'string'
})
.help('h').alias('h', 'help').wrap(null)
.argv Your best bet is probably to just color the descriptions instead of the options/commands themselves, like this: var yargonaut = require('yargonaut')
var chalk = yargonaut.chalk()
var argv = require('yargs')
.command('add', chalk.green('Add a file'), function (yargs) {
console.log('adding')
})
.command('rm', chalk.red('Remove a file'), function (yargs) {
console.log('removing')
})
.demand(1)
.option('f', {
alias: 'file',
describe: chalk.yellow('The file to add or remove'),
demand: true,
type: 'string'
})
.help('h').alias('h', 'help').wrap(null)
.argv That's about all you can do for now. |
I've stepped into the lib and it doesn't apper to do anything, then at some later stage when help is called, some of the values are coloured. If I pass in the keys Clues? |
I can't seem to find a |
If we colour the options like so:
we get duplicate options along with How is this supposed to work? Also how can we get rid of the We also can't have styled help in any way, if we do, the listing just gets duplicated. |
@binarymist Hi 👋 unfortunately I am no longer maintaining yargonaut and it may be incompatible with the latest version of yargs. Please read this for more info. |
Ok, so basicallly the answer is to move to sywac. Although it's really anoying as I've just spent a couple of days on this, I do understand your reasoning and it makes sense. I've seen quite a few times project founders do this, and the second, third project in the same catagory inherits all the learnings (same mistakes not made) from the former projects. I have a few questions:
I'll create a branch and have a crack at sywac, the docs look good on first appearance, although a lot missing. Do you have a contibuting guide? Update. Spent a day on sywac and have ported all of my yargs code. So far it's been an easier setup than yargs. The API is more intuitive, and it's clear to see that @nexdrew has learnt a lot from yargs and applied the learnings to sywac. At this stage the sywac docs are a little lacking, but if you've used yargs, the migrations is intuitive and painless. All the things I was struggling with in yargs are no longer an issue with sywac. Well done @nexdrew ! |
I agree that content & styles should be handled separately. EDIT: yargs.updateStrings({
'Options:': chalk.blue('Options:')
})
... But this would disable auto-locale for the updated string, I guess. yargs.updateStrings({
'Options:': chalk.blue('%$')
})
... But still you cannot style lots of other parts... |
Has sywac been abandoned? I don't see any movement on it for over 6 months and the doc is minimal. |
@davidkjackson54 No, sywac has not been abandoned. It's at a relatively stable point and I use it for all my own CLIs. I just haven't had time to work on the docs or road-mapped features in a long time, and no one else has volunteered to help. I am still maintaining the project and will continue to do so for the foreseeable future. |
Thanks that is great to know. I have a need to be able to support positional parameters for example: where jobs and status are both positional parameters and jname is a required subparm. Are there any samples of how i can accomplish this available? |
Are you asking for yargs or sywac? If you are asking how to do this in sywac, please open an issue there. |
Done |
That would be awesome if we could get colors in the usage description.
The text was updated successfully, but these errors were encountered: