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

Method parse

packages/migrate/src/commands/DbCommand.ts:47–73  ·  view source on GitHub ↗
(argv: string[], config: PrismaConfigInternal, baseDir: string)

Source from the content-addressed store, hash-verified

45 private constructor(private readonly cmds: Commands) {}
46
47 public async parse(argv: string[], config: PrismaConfigInternal, baseDir: string): Promise<string | Error> {
48 const args = arg(argv, {
49 '--help': Boolean,
50 '-h': '--help',
51 '--config': String,
52 '--preview-feature': Boolean,
53 '--telemetry-information': String,
54 })
55
56 if (isError(args)) {
57 return this.help(args.message)
58 }
59
60 // display help for help flag or no subcommand
61 if (args._.length === 0 || args['--help']) {
62 return this.help()
63 }
64
65 // check if we have that subcommand
66 const cmd = this.cmds[args._[0]]
67 if (cmd) {
68 const argsForCmd = args['--preview-feature'] ? [...args._.slice(1), `--preview-feature`] : args._.slice(1)
69 return cmd.parse(argsForCmd, config, baseDir)
70 }
71
72 return unknownCommand(DbCommand.help, args._[0])
73 }
74
75 public help(error?: string): string | HelpError {
76 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