-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
34 lines (27 loc) · 787 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
var ntc = require('./src/ntc');
var program = require('commander');
program
.arguments('<color>')
.action(function(color) {
if (color.substr(0) == '#') {
color = color.substr(1, color.length);
}
// match = [ matchedhex, name, matchedshaderhex, shadername, exactmatch ]
var match = ntc.name(color);
var name = match[1];
var shaderName = match[3].toLowerCase();
var isExact = match[4];
var resp = color + ' is ' + shaderName;
if (name.indexOf('Invalid Color') !== -1) {
console.log('Invalid color');
return;
}
if (isExact)
resp += ' with the exact color name: ';
else
resp += ' with the closest color name: ';
resp += name;
console.log(resp);
})
.parse(process.argv);