-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.js
86 lines (65 loc) · 1.68 KB
/
cli.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env node
import meow from 'meow';
// import isUrl from 'is-url-superb';
// import methods from 'generator or parser to run this thing'
// import { generateFullTemplate2 } from 'atherdon-newsletter-html-replace';
// import { generateReactFullTemplate } from 'atherdon-newsletter-react-replacer';
// https://www.npmjs.com/package/meow
const cli = meow(`
Usage
$ parse
$ parse html
Options
--contentOnly Content Only option [Default: !]
--noAdv Generating template without advertising block
--full Full Template
--empty
--react React DOM version
--reactFull Full template for React template
Example
$ parse html
$ parse react
$ parse --full
$ parse --react
`, {
importMeta: import.meta,
flags: {
contentOnly: {
type: 'boolean',
},
noAdv: {
type: 'boolean',
},
full: {
type: 'boolean',
},
react: {
type: 'boolean',
},
reactFull: {
type: 'boolean',
},
empty: {
type: 'boolean',
},
},
//
// flags: {
// parseParse: {
// type: 'string',
// default: ['html', 'react'],
// isMultiple: false,
// isRequired: (flags, input) => {
// if (flags.otherFlag) {
// return true;
// }
// return false;
// }
// }
// }
});
const [text] = cli.input;
// const method = text == 'html' ? filenamifyUrl : filenamify;
const method = (text == 'html') ? 'PARSE=full node ./src/parser' : 'PARSE=reactContentOnly node ./src/parser';
console.log(text, cli.flags);
// console.log(method(text, cli.flags));