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

Method parse

packages/cli/src/CLI.ts:30–102  ·  view source on GitHub ↗
(argv: string[], config: PrismaConfigInternal, baseDir: string = process.cwd())

Source from the content-addressed store, hash-verified

28 ) {}
29
30 async parse(argv: string[], config: PrismaConfigInternal, baseDir: string = process.cwd()): Promise<string | Error> {
31 const args = arg(argv, {
32 '--help': Boolean,
33 '-h': '--help',
34 '--version': Boolean,
35 '-v': '--version',
36 '--config': String,
37 '--json': Boolean, // for -v
38 '--experimental': Boolean,
39 '--preview-feature': Boolean,
40 '--early-access': Boolean,
41 '--telemetry-information': String,
42 })
43
44 if (isError(args)) {
45 return this.help(args.message)
46 }
47
48 // display help for help flag or no subcommand
49 if (!args['--version'] && (args._.length === 0 || args['--help'])) {
50 return this.help()
51 }
52
53 if (args['--version']) {
54 await ensureNeededBinariesExist({
55 download: this.download,
56 })
57 return Version.new().parse(argv, config, baseDir)
58 }
59
60 // check if we have that subcommand
61 const cmdName = args._[0]
62 // Throw if "lift"
63 if (cmdName === 'lift') {
64 throw new Error(`${red('prisma lift')} has been renamed to ${green('prisma migrate')}`)
65 }
66
67 const cmd = this.cmds[cmdName]
68 if (cmd) {
69 // Only track if the command actually exists
70 const checkResultPromise = runCheckpointClientCheck({ schemaPathFromConfig: config.schema, baseDir }).catch(
71 () => {
72 /* noop */
73 },
74 )
75
76 // if we have that subcommand, let's ensure that the binary is there in case the command needs it
77 if (this.ensureBinaries.includes(cmdName)) {
78 await ensureNeededBinariesExist({
79 download: this.download,
80 })
81 }
82
83 let argsForCmd: string[]
84 if (args['--experimental']) {
85 argsForCmd = [...args._.slice(1), `--experimental=${args['--experimental']}`]
86 } else if (args['--preview-feature']) {
87 argsForCmd = [...args._.slice(1), `--preview-feature=${args['--preview-feature']}`]

Callers

nothing calls this directly

Calls 12

helpMethod · 0.95
argFunction · 0.90
isErrorFunction · 0.90
runCheckpointClientCheckFunction · 0.90
printUpdateMessageFunction · 0.90
unknownCommandFunction · 0.90
catchMethod · 0.80
includesMethod · 0.80
parseMethod · 0.65
newMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected