UNPKG

colorpath

Version:
42 lines (36 loc) 1.09 kB
#!/usr/bin/env node var meow = require('meow') var clp = require('../lib/colorpath') var cli = meow(` Usage $ clp <arguments> <method> Methods -t, --tint tint <source> color with a <percentage> -s, --shade shade <source> color with a <percentage> -m, --mix mix <source> color and <mixer> color with a <percentage> --find-tint find the percentage with which <source> color is tinted to <destination> color --find-shade find the percentage with which <source> color is shaded to <destination> color --find-path find which path <source> color should take to get to <destination> color Examples $ clp FF08D5 0.4 -t `, { alias: { t: 'tint', s: 'shade', m: 'mix' } }) var flags = Object.keys(cli.flags) var method cli.input.forEach((item, index) => { if (item > 1) { cli.input[index] = ('000000' + item).slice(-6) } }) if (flags.length === 0) { cli.showHelp() } else { method = flags[flags.length - 1] if (!clp[method]) cli.showHelp() console.log(clp[method].apply(null, cli.input)) }