-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathparse_args.ts
65 lines (60 loc) · 1.56 KB
/
parse_args.ts
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
export type ParsedArgs = {
help: boolean
buildLibraries: boolean
buildOnly: boolean
printVersion: boolean
init: boolean
debug: boolean
tsgdPath?: string
}
export const parseArgs = (): ParsedArgs => {
const args = process.argv.slice(2)
const flags: ParsedArgs = {
help: false,
buildLibraries: false,
buildOnly: false,
printVersion: false,
init: false,
debug: false,
}
for (const arg of args) {
if (arg.trim().length === 0) {
continue
}
if (arg === "--help") {
flags.help = true
} else if (arg === "--buildLibraries") {
flags.buildLibraries = true
} else if (arg === "--buildOnly") {
flags.buildOnly = true
} else if (arg === "--version") {
flags.printVersion = true
} else if (arg === "--debug") {
flags.debug = true
} else if (arg === "--init") {
flags.init = true
} else if (arg.includes("/") || arg.includes(".json")) {
flags.tsgdPath = arg
} else {
flags.help = true
}
}
return flags
}
export const printHelp = () => {
console.info()
console.info("Arguments:")
console.info(
"--buildLibraries Force ts2gd to regenerate the TypeScript definitions for Godot."
)
console.info(
"--buildOnly Compiles the project to TypeScript and immediately exits."
)
console.info("--init Initialize a ts2gd project here.")
console.info("--help Print this help.")
console.info()
console.info()
console.info(
"See README on GitHub for much more detail: https://github.com/johnfn/ts2gd"
)
}