-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 1.02 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
'use strict';
const {program, Option} = require('commander');
const cmdCreatePlaylist = require('./cmd/create-playlist');
const cmdGetToken = require('./cmd/get-token');
const version = '1.0.0';
// Basic metadata
program
.name('session-maker-for-spotify')
.description('Create Spotify sessions using multiple playlists')
.version(version);
// Commands
program.command('create-playlist')
.description('Create playlist based on a session file')
.addOption(new Option('-a --access-token <key>', 'Spotify Access token').env('ACCESS_TOKEN')
.makeOptionMandatory())
.addOption(new Option('-s --session <file>', 'Session definition').env('SESSION_FILE')
.makeOptionMandatory())
.action((opts) => {
if (!opts.accessToken) {
throw new Error('Missing access token. Please execute "session-maker-for-spotify get-token"');
}
cmdCreatePlaylist(opts);
});
program.command('get-token')
.description('Get token for accessing the Spotify API')
.action((opts) => {
cmdGetToken(opts);
});
program.parse();