forked from microsoft/devicescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
129 lines (116 loc) · 4.43 KB
/
cli.ts
File metadata and controls
129 lines (116 loc) · 4.43 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { program } from "commander"
import pkg from "../package.json"
import { annotate } from "./annotate"
import { build } from "./build"
import { crunScript } from "./crun"
import { ctool } from "./ctool"
import { deployScript } from "./deploy"
import { devtools } from "./devtools"
import { disasm } from "./disasm"
import init from "./init"
import { logParse } from "./logparse"
import { runScript } from "./run"
export async function mainCli() {
program
.name("DeviceScript")
.description(
"build and run DeviceScript program https://aka.ms/devicescript"
)
.version(pkg.version)
.option("-v, --verbose", "more logging")
program
.command("build", { isDefault: true })
.description("build a DeviceScript file")
.option("-s, --stats", "show additional size information")
.option("-l, --library", "build library")
.option("--no-verify", "don't verify resulting bytecode")
.option("-o", "--out-dir", "output directory, default is 'built'")
.option("-w, --watch", "watch file changes and rebuild automatically")
.option("--internet", "allow connections from non-localhost")
.option(
"--localhost",
"use localhost:8000 instead of the internet dashboard"
)
.option("-t, --tcp", "open native TCP socket at 8082")
.arguments("[file.ts]")
.action(build)
program
.command("init")
.description("configures the current directory for devicescript")
.option("-f, --force", "force overwrite existing files")
.option("--spaces <number>", "number of spaces when generating JSON")
.action(init)
program
.command("devtools")
.description("launches a local deveplopement tools server")
.option("--internet", "allow connections from non-localhost")
.option(
"--localhost",
"use localhost:8000 instead of the internet dashboard"
)
.option("-t, --tcp", "open native TCP socket at 8082")
.action(devtools)
program
.command("ctool", { hidden: true })
.description("access to internal compilation tools")
.option("--empty", "generate empty program embed")
.option("-t, --test", "run compiler tests")
.action(ctool)
program
.command("logparse", { hidden: true })
.description("parse binary log file from SD card")
.option(
"-g, --generation <number>",
"give details for a specific generation; otherwise generations are just listed"
)
.option("-s, --stats", "only print stats, not content")
.arguments("<log_xxx.jdl>")
.action(logParse)
program
.command("run")
.description("run a script")
.option(
"--tcp",
"use tcp jacdac proxy on 127.0.0.1:8082 (otherwise ws://127.0.0.1:8081)"
)
.option("-t, --test", "run in test mode (no sockets, no restarts)")
.option(
"-T, --test-timeout <milliseconds>",
"set timeout for --test mode (default: 2000ms)"
)
.option("-w, --wait", "wait for external deploy")
.arguments("[file.ts|file.devs]")
.action(runScript)
// this talks direct jacdac packets, it doesn't work with current devtools (since they do not forward jacdac packets)
// hide it until we have a better story
program
.command("deploy", { hidden: true })
.description("deploy a script over jacdac proxy")
.option(
"--tcp",
"use tcp jacdac proxy on 127.0.0.1:8082 (otherwise ws://127.0.0.1:8081)"
)
.arguments("<file.ts|file.devs>")
.action(deployScript)
program
.command("crun", { hidden: true })
.description("run a script using native runner")
.option("-n, --net", "connect to 127.0.0.1:8082 for Jacdac proxy")
.option(
"-s, --serial <serial-port>",
"connect to serial port, not 127.0.0.1:8082"
)
.arguments("<file.ts|file.devs>")
.action(crunScript)
program
.command("disasm")
.description("disassemble .devs binary")
.arguments("<file.ts|file.devs>")
.action(disasm)
program
.command("annotate")
.description("annotate stack frames in stdin")
.action(annotate)
program.parse(process.argv)
}
if (require.main === module) mainCli()