forked from ferrislucas/promptr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcliState.js
68 lines (51 loc) · 1.71 KB
/
cliState.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
import { Command } from 'commander'
export default class CliState {
program = null
args = null
static init(_args, version) {
this.program = new Command();
this.program.option('-d, --dry-run', 'Dry run only: just display the prompt')
this.program.option('-i, --interactive', 'Interactive mode');
this.program.option('-p, --prompt <prompt>', 'Prompt to use in non-interactive mode');
this.program.option('-t, --template-path <templatePath>', 'Path to template file')
this.program.option('-o, --output-path <outputPath>', 'Path to output file. If no path is specified, output will be printed to stdout.')
this.program.option('-v, --verbose', 'Verbose output')
this.program.requiredOption('-m, --mode <mode>', 'Specify the mode: (gpt3|gpt4)')
this.program.version(version, '--version', 'Display the current version')
this.program.addHelpText('after', `
Example call:
$ promptr -m gpt3 index.js -o index.js -p "Cleanup the code in this file"`);
this.program.parse(_args);
this.args = this.program.args
}
static opts() {
return this.program.opts()
}
static verbose() {
return this.program.opts().verbose
}
static version() {
return this.program.opts().version
}
static getMode() {
return this.program.opts().mode
}
static getOutputPath() {
return this.program.opts().outputPath
}
static getTemplatePath() {
return this.program.opts().templatePath
}
static getPrompt() {
return this.program.opts().prompt
}
static isDryRun() {
return this.program.opts().dryRun
}
static isInteractive() {
return this.program.opts().interactive
}
static getExecutePath() {
return this.program.opts().execute
}
}