-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.ts
39 lines (32 loc) · 1.35 KB
/
start.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
import { getPlebbitLogger } from "../../../util.js";
import { BaseCommand } from "../../base-command.js";
import { Args } from "@oclif/core";
export default class Start extends BaseCommand {
static override description = "Start a subplebbit";
static override strict = false; // To allow for variable length arguments
static override args = {
addresses: Args.string({
name: "addresses", // name of arg to show in help and reference with args[name]
required: true,
description: "Addresses of subplebbits to start. Separated by space"
})
};
static override examples = [
"plebbit subplebbit start plebbit.eth",
"plebbit subplebbit start 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu"
];
async run() {
const { argv, flags } = await this.parse(Start);
const addresses = <string[]>argv;
const log = (await getPlebbitLogger())("plebbit-cli:commands:subplebbit:start");
log(`addresses: `, addresses);
log(`flags: `, flags);
const plebbit = await this._connectToPlebbitRpc(flags.plebbitRpcUrl.toString());
for (const address of addresses) {
const sub = await plebbit.createSubplebbit({ address });
await sub.start();
this.log(address);
}
await plebbit.destroy();
}
}