-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (49 loc) · 1.25 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
var programm = require('commander');
var inquirer = require('inquirer');
var google = require('./lib/providers/google');
var actions = require('./cli-actions');
programm
.version(require('./package').version)
.usage('[options]')
.option('-f, --favorites', 'show the list of favorite songs')
.option('-p, --playlist [num]', 'show the list of songs for playlist')
.option('-s, --search [text]', 'search')
.option('--path [text]', 'download folder. ~/.gmsync is default')
.option('-d, --download', 'download songs and sync with iTunes')
.parse(process.argv);
if (programm.favorites || programm.search || programm.playlist) {
return actions(programm);
}
google.getPlayLists(function (err, playlists) {
if (err) {
return console.error(err);
}
var playlistQ = {
type: 'list',
message: 'Playlist',
name: 'playlist',
choices: playlists.map(function (item, index) {
return {
name: index + '. ' + item.name,
value: index
};
})
};
var actionQ = {
type: 'list',
message: 'Action',
name: 'action',
choices: [
'print',
'download'
]
};
inquirer.prompt([playlistQ, actionQ], function (aswers) {
actions({
path: programm.path,
playlist: aswers.playlist,
download: aswers.action === 'download'
});
});
});