-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
52 lines (44 loc) · 1.5 KB
/
app.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
import {program} from 'commander';
import {ssg_} from './index.js';
import {readFile} from 'fs/promises';
const json = JSON.parse(
await readFile(new URL('./package.json', import.meta.url))
);
program
.option('-v, --version', 'output the current version')
.option('-i, --input <item>', 'gets the input')
.option('-h, --help', 'help')
.option('-l, --lang <item>', 'gets the language')
.option('-c, --config <item>', 'get the config');
program.parse(process.argv);
if (program.version) {
console.log('Name of the package: ' + ' ag-ssg');
console.log('Version details: ' + json.version);
}
if (program.opts().help) {
console.log(
'To run the code in terminal \n' +
'npm install \n' +
'npm link \n' +
'node app.js -i <item> select the file or directory\n' +
'node app.js -v --version to get the version details\n' +
'node app.js -h --help to get the option \n' +
'node app.js -l --lang option for language support \n' +
'node app.js -c --config option for config support \n' +
'Need to install all the dependencies such as npm install , npm links , Build and run the project\n'
);
}
if (program.opts().input) {
console.log('input:' + program.opts().input);
ssg_(`${program.opts().input}`);
}
if (program.opts().lang) {
console.log('language:' + program.opts().lang);
ssg_(`${program.opts().input}`, `${program.opts().lang}`);
}
if (program.opts().config) {
console.log('config: ' + program.opts().config);
ssg_(null, null, program.opts().config);
}
export {program};