MCPcopy Create free account
hub / github.com/cameri/nostream / runManageMenu

Function runManageMenu

src/cli/tui/menus/manage.ts:7–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import ora from 'ora'
6
7export const runManageMenu = async (): Promise<number> => {
8 const action = await tuiPrompts.select({
9 message: 'Data management',
10 options: [
11 { value: 'export', label: 'Export events' },
12 { value: 'import', label: 'Import events' },
13 { value: 'back', label: 'Back' },
14 ],
15 })
16
17 if (tuiPrompts.isCancel(action)) {
18 tuiPrompts.cancel('Cancelled')
19 return 1
20 }
21 if (action === 'back') {
22 return 0
23 }
24
25 if (action === 'export') {
26 const format = await tuiPrompts.select({
27 message: 'Output format',
28 options: [
29 { value: 'jsonl', label: 'JSON Lines (.jsonl)' },
30 { value: 'json', label: 'JSON array (.json)' },
31 { value: 'back', label: 'Back' },
32 ],
33 })
34 if (tuiPrompts.isCancel(format)) {
35 tuiPrompts.cancel('Cancelled')
36 return 1
37 }
38 if (format === 'back') {
39 return 0
40 }
41
42 const output = await tuiPrompts.text({
43 message: 'Output filename',
44 defaultValue: format === 'json' ? 'events.json' : 'events.jsonl',
45 })
46 if (tuiPrompts.isCancel(output)) {
47 tuiPrompts.cancel('Cancelled')
48 return 1
49 }
50
51 const confirmed = await tuiPrompts.confirm({
52 message: `Export events to ${output}?`,
53 initialValue: true,
54 })
55 if (tuiPrompts.isCancel(confirmed) || !confirmed) {
56 tuiPrompts.cancel('Cancelled')
57 return 1
58 }
59
60 const spinner = ora('Exporting events...').start()
61 const code = await runExport({ output, format: format as 'json' | 'jsonl' }, [])
62 if (code === 0) {
63 spinner.succeed('Export completed')
64 } else {

Callers 1

runTuiFunction · 0.90

Calls 3

runExportFunction · 0.90
logErrorFunction · 0.90
runImportFunction · 0.90

Tested by

no test coverage detected