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

Function parseCliArgs

src/import-events.ts:60–111  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

58}
59
60export const parseCliArgs = (args: string[]): CliOptions => {
61 let batchSize = DEFAULT_BATCH_SIZE
62 let filePath: string | undefined
63
64 if (args.includes('--help') || args.includes('-h')) {
65 return {
66 batchSize,
67 filePath: '',
68 showHelp: true,
69 }
70 }
71
72 for (let i = 0; i < args.length; i++) {
73 const arg = args[i]
74
75 if (arg === '--batch-size') {
76 const nextArg = args[i + 1]
77 if (typeof nextArg !== 'string') {
78 throw new Error('Missing value for --batch-size')
79 }
80
81 batchSize = parseBatchSize(nextArg)
82 i += 1
83 continue
84 }
85
86 if (arg.startsWith('--batch-size=')) {
87 batchSize = parseBatchSize(arg.split('=', 2)[1])
88 continue
89 }
90
91 if (arg.startsWith('-')) {
92 throw new Error(`Unknown option: ${arg}`)
93 }
94
95 if (filePath) {
96 throw new Error(`Unexpected extra argument: ${arg}`)
97 }
98
99 filePath = arg
100 }
101
102 if (!filePath) {
103 throw new Error('Missing path to .jsonl or .json file')
104 }
105
106 return {
107 batchSize,
108 filePath,
109 showHelp: false,
110 }
111}
112
113const inferCompressedFormat = (absolutePath: string): ImportFileFormat | undefined => {
114 const normalized = absolutePath.toLowerCase()

Callers 2

runImportEventsFunction · 0.70

Calls 1

parseBatchSizeFunction · 0.85

Tested by

no test coverage detected