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

[Pull Request?] I have created a CLI for this #126

Closed
NightMachinery opened this issue Aug 13, 2019 · 1 comment
Closed

[Pull Request?] I have created a CLI for this #126

NightMachinery opened this issue Aug 13, 2019 · 1 comment

Comments

@NightMachinery
Copy link

NightMachinery commented Aug 13, 2019

I have created a CLI for this, which I think other people might find useful. I'm not at all familiar with node and Javascript. Should I create a new package and repo like https://github.com/chalk/chalk-cli does for chalk? Or should it be merged here?

#!/usr/bin/env node
// You can pipe the JSON output to `jq -re '.[]'` for easy consumption.
const program = require('commander');
var randomColor = require('randomcolor'); // import the script

program.option('-u, --hue <hue>', 'Controls the hue of the generated color. You can pass a string representing a color name: red, orange, yellow, green, blue, purple, pink and monochrome are currently supported. If you pass a hexidecimal color string such as #00FFFF, randomColor will extract its hue value and use that to generate colors.', 'random');
program.option('-l, --luminosity <luminosity>', 'Controls the luminosity of the generated color. You can specify a string containing bright, light or dark.', 'random');
program.option('-c, --count <count>', 'An integer which specifies the number of colors to generate.', '1');
program.option('-s, --seed <seed>', 'An integer or string which when passed will cause randomColor to return the same color each time. The default value is generated using Math.random.', Math.random().toString());
program.option('-f, --format <format>', 'A string which specifies the format of the generated color. Possible values are rgb, rgba, rgbArray, hsl, hsla, hslArray and hex.', 'rgb');
program.option('-a, --alpha <alpha>', ' A decimal between 0 and 1. Only relevant when using a format with an alpha channel (rgba and hsla).', '1');

program.parse(process.argv);

console.log(JSON.stringify(randomColor({
    hue: program.hue,
    count: program.count,
    luminosity: program.luminosity,
    format: program.format,
    alpha: program.alpha,
    seed: program.seed
})));
@davidmerfield
Copy link
Owner

Hello! Please create your own repo, distribute the CLI and I'd more than happy to accept a PR adding to a link to your project to this project's README

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

No branches or pull requests

2 participants