MCPcopy Index your code
hub / github.com/cameri/nostream / runStartMenu

Function runStartMenu

src/cli/tui/menus/start.ts:5–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import ora from 'ora'
4
5export const runStartMenu = async (): Promise<number> => {
6 const action = await tuiPrompts.select({
7 message: 'Start relay',
8 options: [
9 { value: 'continue', label: 'Continue' },
10 { value: 'back', label: 'Back' },
11 ],
12 })
13 if (tuiPrompts.isCancel(action)) {
14 tuiPrompts.cancel('Cancelled')
15 return 1
16 }
17 if (action === 'back') {
18 return 0
19 }
20
21 const tor = await tuiPrompts.confirm({ message: 'Enable Tor?', initialValue: false })
22 if (tuiPrompts.isCancel(tor)) {
23 tuiPrompts.cancel('Cancelled')
24 return 1
25 }
26
27 const i2p = await tuiPrompts.confirm({ message: 'Enable I2P?', initialValue: false })
28 if (tuiPrompts.isCancel(i2p)) {
29 tuiPrompts.cancel('Cancelled')
30 return 1
31 }
32
33 const debug = await tuiPrompts.confirm({ message: 'Enable debug logs?', initialValue: false })
34 if (tuiPrompts.isCancel(debug)) {
35 tuiPrompts.cancel('Cancelled')
36 return 1
37 }
38
39 const useCustomPort = await tuiPrompts.confirm({ message: 'Override relay port?', initialValue: false })
40 if (tuiPrompts.isCancel(useCustomPort)) {
41 tuiPrompts.cancel('Cancelled')
42 return 1
43 }
44
45 let port: number | undefined
46 if (useCustomPort) {
47 const portInput = await tuiPrompts.text({
48 message: 'Relay port (1-65535)',
49 defaultValue: '8008',
50 validate: (input) => {
51 const parsed = Number(input)
52 if (!Number.isSafeInteger(parsed) || parsed < 1 || parsed > 65535) {
53 return 'Port must be a safe integer between 1 and 65535'
54 }
55 return undefined
56 },
57 })
58 if (tuiPrompts.isCancel(portInput)) {
59 tuiPrompts.cancel('Cancelled')
60 return 1
61 }
62

Callers 1

runTuiFunction · 0.90

Calls 1

runStartFunction · 0.90

Tested by

no test coverage detected