MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / run

Function run

scripts/dev-select.mjs:57–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57function run() {
58 console.log('\n\x1b[1mSelect dev mode:\x1b[0m (↑↓ to move, Enter to confirm)\n')
59 for (let i = 0; i < options.length; i++) process.stdout.write('\n')
60 render()
61
62 process.stdin.setRawMode(true)
63 process.stdin.resume()
64 process.stdin.setEncoding('utf8')
65
66 process.stdin.on('data', (key) => {
67 if (key === '\x1b[A') {
68 selected = (selected - 1 + options.length) % options.length
69 render()
70 } else if (key === '\x1b[B') {
71 selected = (selected + 1) % options.length
72 render()
73 } else if (key === '\r' || key === '\n') {
74 process.stdin.setRawMode(false)
75 process.stdin.pause()
76 const choice = options[selected]
77 saveChoice(choice.key)
78 console.log(`\n\x1b[32m▶\x1b[0m Running: ${choice.command}\n`)
79 try {
80 execSync(choice.command, { stdio: 'inherit' })
81 } catch {
82 process.exit(1)
83 }
84 } else if (key === '\x03') {
85 process.stdin.setRawMode(false)
86 console.log()
87 process.exit(0)
88 }
89 })
90}
91
92run()

Callers 1

dev-select.mjsFile · 0.70

Calls 5

saveChoiceFunction · 0.85
onMethod · 0.80
renderFunction · 0.70
writeMethod · 0.65
pauseMethod · 0.65

Tested by

no test coverage detected