MCPcopy
hub / github.com/prisma/prisma / parse

Method parse

packages/migrate/src/CLI.ts:17–57  ·  view source on GitHub ↗
(argv: string[], config: PrismaConfigInternal, baseDir: string)

Source from the content-addressed store, hash-verified

15 private constructor(private readonly cmds: Commands) {}
16
17 async parse(argv: string[], config: PrismaConfigInternal, baseDir: string): Promise<string | Error> {
18 const args = arg(argv, {
19 '--help': Boolean,
20 '-h': '--help',
21 '--config': String,
22 '--json': Boolean, // for -v
23 '--experimental': Boolean,
24 '--preview-feature': Boolean,
25 '--early-access': Boolean,
26 '--telemetry-information': String,
27 })
28
29 if (isError(args)) {
30 return this.help(args.message)
31 }
32
33 // display help for help flag or no subcommand
34 if (args._.length === 0 || args['--help']) {
35 return this.help()
36 }
37
38 // check if we have that subcommand
39 const cmdName = args._[0]
40 const cmd = this.cmds[cmdName]
41 if (cmd) {
42 let argsForCmd: string[]
43 if (args['--experimental']) {
44 argsForCmd = [...args._.slice(1), `--experimental=${args['--experimental']}`]
45 } else if (args['--preview-feature']) {
46 argsForCmd = [...args._.slice(1), `--preview-feature=${args['--preview-feature']}`]
47 } else if (args['--early-access']) {
48 argsForCmd = [...args._.slice(1), `--early-access=${args['--early-access']}`]
49 } else {
50 argsForCmd = args._.slice(1)
51 }
52
53 return cmd.parse(argsForCmd, config, baseDir)
54 }
55 // unknown command
56 return unknownCommand(this.help() as string, args._[0])
57 }
58
59 public help(error?: string) {
60 if (error) {

Callers

nothing calls this directly

Calls 6

helpMethod · 0.95
argFunction · 0.90
isErrorFunction · 0.90
unknownCommandFunction · 0.90
parseMethod · 0.65
sliceMethod · 0.45

Tested by

no test coverage detected