-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
executable file
·40 lines (30 loc) · 937 Bytes
/
cli.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
35
36
37
38
39
40
#!/usr/bin/env node
'use strict'
import meow from 'meow';
import convertColor from './convertColor.js';
const cli = meow(`
Examples
# rgb
$ convert-color 'rgb(40, 42, 54)'
# alpha values can be % or decimal
$ convert-color 'rgba(40, 42, 54, 75%)'
$ convert-color 'rgba(40, 42, 54, 0.75)'
# hex
$ convert-color ff9afd
# can have a pound sign at beginning
$ convert-color '#282a36'
# works with 8 digit hex codes (opacity)
$ convert-color 282a36bf
# hsl
$ convert-color 'hsl(336, 100%, 50%)'
# alpha values can be % or decimal
$ convert-color 'hsla(336, 100%, 50%, 75%)'
$ convert-color 'hsla(336, 100%, 50%, 0.75)'
# you can also omit a color and input it using the interactive input
$ convert-color
Enter the color you want to convert:
`, {
importMeta: import.meta
})
const initialColor = cli.input.length === 0 ? null : cli.input.join(' ');
export default convertColor(initialColor);