MCPcopy Create free account
hub / github.com/effect-app/libs / parseArgs

Function parseArgs

packages/eslint-codegen-model/src/cli.ts:458–513  ·  view source on GitHub ↗
(args: ReadonlyArray<string>)

Source from the content-addressed store, hash-verified

456}
457
458function parseArgs(args: ReadonlyArray<string>): ParsedArgs {
459 const files: Array<string> = []
460 let config: string | undefined
461 let tsconfig: string | undefined
462 // Native (tsgo) is the default resolver; `--legacy` opts back into the classic
463 // `typescript` Compiler API. `--native` is kept as an accepted no-op.
464 let native = true
465
466 for (let index = 0; index < args.length; index++) {
467 const part = args[index]!
468 if (part === "--help" || part === "-h") {
469 return { files, help: true }
470 }
471 if (part === "--file") {
472 const next = args[index + 1]
473 if (!next) {
474 throw new Error("Missing value for --file")
475 }
476 files.push(path.resolve(process.cwd(), next))
477 index++
478 continue
479 }
480 if (part === "--config") {
481 const next = args[index + 1]
482 if (!next) {
483 throw new Error("Missing value for --config")
484 }
485 config = next
486 index++
487 continue
488 }
489 if (part === "--tsconfig") {
490 const next = args[index + 1]
491 if (!next) {
492 throw new Error("Missing value for --tsconfig")
493 }
494 tsconfig = path.resolve(process.cwd(), next)
495 index++
496 continue
497 }
498 if (part === "--native") {
499 native = true
500 continue
501 }
502 if (part === "--legacy" || part === "--classic") {
503 native = false
504 continue
505 }
506 throw new Error(`Unknown argument: ${part}`)
507 }
508
509 const result: ParsedArgs = { files, help: false, native }
510 if (config !== undefined) result.config = config
511 if (tsconfig !== undefined) result.tsconfig = tsconfig
512 return result
513}
514
515// A model block requests type-checker-backed literal interfaces via `static: true`

Callers 1

runFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…