-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (33 loc) · 1.08 KB
/
index.js
File metadata and controls
39 lines (33 loc) · 1.08 KB
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
const { program } = require('commander');
const { version } = require('./package.json');
const { startInteractive, currentDownloadPath } = require('./utils/input');
const { showBanner, showStatusFooter } = require('./utils/helpers');
const { PLATFORM_CONFIG } = require('./utils/config');
program
.name('prnvapp')
.description('Social Media Downloader CLI')
.version(version)
.option('-p, --path <directory>', 'Custom download directory (default: "resultdownload_preniv")', 'resultdownload_preniv');
program
.command('interactive')
.alias('i')
.description('Start interactive mode')
.action(startInteractive);
PLATFORM_CONFIG.forEach(platform => {
const cmd = program.command(`${platform.command} <url>`);
if (platform.alias) {
cmd.alias(platform.alias);
}
cmd
.description(`Download from ${platform.name}`)
.action(async (url) => {
showBanner();
await platform.handler(url, program.opts().path || currentDownloadPath);
showStatusFooter();
});
});
if (process.argv.length === 2) {
startInteractive();
} else {
program.parse();
}