forked from nmshd/connector-tui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
65 lines (59 loc) · 1.57 KB
/
index.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
import chalk from "chalk"
import prompts from "prompts"
import {
acceptAllRelationships,
CONNECTOR_CLIENT,
createComplexQRCode,
createSimpleQRCode,
sendMessage,
uploadFile,
} from "./lib"
const connectorVersionInfo = await CONNECTOR_CLIENT.monitoring.getVersion()
if (!connectorVersionInfo.version.startsWith("3.")) {
console.log(
`This TUI is made for Enmeshed V2 connectors (starting with version 3.0.0 of the connector). Current version: ${connectorVersionInfo.version}`
)
process.exit(1)
}
console.log(`Welcome to the ${chalk.blue("Enmeshed V2 TUI")}!`)
console.log(`TUI Version: ${chalk.yellow(process.env.npm_package_version)}`)
console.log(`Connector version: ${chalk.yellow(connectorVersionInfo.version)}`)
console.log("")
let running = true
while (running) {
const result = await prompts({
type: "select",
name: "action",
message: "What do you want to do?",
choices: [
{ title: "Complex QR Code", value: 1 },
{ title: "Simple QR Code", value: 2 },
{ title: "Accept All Relationships", value: 3 },
{ title: "Upload File", value: 4 },
{ title: "Send Message", value: 5 },
{ title: "Exit", value: "exit" },
],
})
if (!result.action) break
switch (result.action) {
case 1:
await createComplexQRCode()
break
case 2:
await createSimpleQRCode()
break
case 3:
await acceptAllRelationships()
break
case 4:
await uploadFile()
break
case 5:
await sendMessage()
break
case "exit":
default:
running = false
break
}
}