-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrm.ts
More file actions
39 lines (31 loc) · 1.25 KB
/
rm.ts
File metadata and controls
39 lines (31 loc) · 1.25 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
import { Arg, Command, Env } from "./lib/command.js";
import { stdout, stderr } from "process";
import { getDevice } from "./util.js";
const cmd = new Command("Delete a file on device", {
action: async (options: Record<string, string | boolean>, args: Record<string, string>, env: Env) => {
const port = options["port"] as string;
const baudrate = options["baudrate"] as string;
const socket = options["socket"] as string;
const ble = options["ble"] as string | undefined;
const path = args["path"] as string;
const device = await getDevice(port, baudrate, socket, ble, env);
await device.controller.lock().catch((err) => {
stderr.write("Error locking device: " + err + "\n");
throw 1;
});
const cmd = await device.uploader.deleteFile(path).catch((err) => {
stderr.write("Error: " + err + "\n");
throw 1;
});
await device.controller.unlock().catch((err) => {
stderr.write("Error unlocking device: " + err + "\n");
throw 1;
});
stdout.write(cmd.toString() + "\n");
},
args: [
new Arg("path", "File to delete", { required: true }),
],
chainable: true
});
export default cmd;