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

Function getOptionValue

src/scripts/export-events.ts:89–107  ·  view source on GitHub ↗
(option: string, args: string[], index: number)

Source from the content-addressed store, hash-verified

87}
88
89const getOptionValue = (option: string, args: string[], index: number): [string, number] => {
90 const inlineSeparator = `${option}=`
91 if (args[index].startsWith(inlineSeparator)) {
92 const value = args[index].slice(inlineSeparator.length)
93 if (!value) {
94 throw new Error(`Missing value for ${option}`)
95 }
96
97 return [value, index]
98 }
99
100 const nextIndex = index + 1
101 const nextArg = args[nextIndex]
102 if (typeof nextArg !== 'string' || nextArg.startsWith('-')) {
103 throw new Error(`Missing value for ${option}`)
104 }
105
106 return [nextArg, nextIndex]
107}
108
109const printUsage = (): void => {
110 console.log('Usage: pnpm run export [output-file] [--compress|-z] [--format gzip|gz|xz]')

Callers 1

parseCliArgsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected