-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (33 loc) · 1007 Bytes
/
index.js
File metadata and controls
39 lines (33 loc) · 1007 Bytes
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
import program from 'commander';
import { listPath, tablePath } from './paths/paths.js';
import * as VAR from './common/variables.js';
program.version('1.0.0').description('Our first awesome CLI');
program
.command('list')
.alias('l')
.option(
'-lt, --type [type]',
'ordered or unordered list (ol/ul), default is ul',
)
.option('-t, --title [title]', 'title of your html')
.action(async ({ type, title }) => {
try {
const listTemplateFile =
type === 'ol' ? VAR.OL_TEMPLATE : VAR.UL_TEMPLATE;
await listPath(listTemplateFile, title);
} catch (err) {
console.log(err);
}
});
program
.command('table')
.alias('t')
.option('-t, --title [title]', 'title of your html')
.action(async ({ title }) => {
try {
await tablePath(VAR.TABLE_TEMPLATE, title);
} catch (err) {
console.log(err);
}
});
program.parse(process.argv);