-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·88 lines (82 loc) · 1.99 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
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
87
88
#!node
const generate = require("./generate").generate;
const { argv } = require("process");
const yargs = require("yargs");
yargs.version("1.0.0");
yargs
.command("generate", "Generate a post")
.options({
prompt: {
alias: "p",
describe: "Prompt to generate content",
demandOption: true,
type: "string",
},
output: {
alias: "o",
describe: "Output filename",
demandOption: true,
type: "string",
},
tone: {
alias: "t",
describe: "Tone of the content",
demandOption: false,
type: "number",
choices: [1, 2, 3, 4, 5],
default: 4,
description:
"1: Professional, 2: Casual, 3: Enthusiastic, 4: Informational, 5: Funny",
defaultDescription: "Informational",
requiresArg: false,
},
format: {
alias: "f",
describe: "Format of the content",
demandOption: false,
type: "number",
choices: [1, 2, 3, 4],
defaultDescription: "Blog Post",
description: "1: Paragraph, 2: Email, 3: Blog Post, 4: Chat",
default: 4,
requiresArg: false,
},
length: {
alias: "l",
describe: "Length of the content",
demandOption: false,
type: "number",
choices: [1, 2, 3],
default: 3,
description: "1: Short, 2: Medium, 3: Long",
defaultDescription: "Medium",
requiresArg: false,
},
headless: {
alias: "h",
describe: "Run in headless mode",
demandOption: false,
type: "boolean",
default: false,
defaultDescription: "true",
requiresArg: false,
},
})
.default("help").argv;
let prompt = yargs.argv.prompt;
// check if prompt text is path to file with check if file exists
const fs = require("fs");
if (fs.existsSync(prompt)) {
prompt = fs.readFileSync(prompt, "utf8");
}
const main = async () => {
await generate(
prompt,
yargs.argv.output,
yargs.argv.tone,
yargs.argv.format,
yargs.argv.length,
yargs.argv.headless
);
};
main();