-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
cli.js
60 lines (43 loc) · 849 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
'use strict'
const meow = require( 'meow' )
const albumArt = require( '.' )
const cli = meow( `
Usage
$ album-art artist [album] [size]
Options
--album, -a Optionally search for a specific album art
--size, -s Possible values: [small|medium|large]
Example
$ album-art 'The Beatles' --album 'Abbey Road' --size 'large'
// => http://path/to/beatles/album.jpg
`, {
flags: {
album: {
type: 'string',
alias: 'a'
},
size: {
type: 'string',
alias: 's'
}
}
} )
const opts = {
album: null,
size: null
}
if ( cli.flags.a ) {
opts.album = cli.flags.a
}
if ( cli.flags.s ) {
opts.size = cli.flags.s
}
if ( cli.input[1] ) {
opts.album = cli.input[1]
}
if ( !cli.input[0] ) {
cli.showHelp()
}
// Search artist, album and size
albumArt( cli.input[0], opts ).then( console.log )