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

Method parse

packages/cli/src/Init.ts:326–743  ·  view source on GitHub ↗
(argv: string[], _config: PrismaConfigInternal)

Source from the content-addressed store, hash-verified

324 `)
325
326 async parse(argv: string[], _config: PrismaConfigInternal): Promise<string | Error> {
327 const args = arg(argv, {
328 '--help': Boolean,
329 '-h': '--help',
330 '--url': String,
331 '--datasource-provider': String,
332 '--generator-provider': String,
333 '--preview-feature': [String],
334 '--output': String,
335 '--with-model': Boolean,
336 '--db': Boolean,
337 '--region': String,
338 '--name': String,
339 '--non-interactive': Boolean,
340 '--prompt': String,
341 '--vibe': String,
342 '--debug': Boolean,
343 })
344
345 if (isError(args) || args['--help']) {
346 return this.help()
347 }
348
349 const urlArg = args['--url']
350
351 if (urlArg) {
352 checkUnsupportedDataProxy({
353 cmd: 'init',
354 validatedConfig: { datasource: { url: urlArg } },
355 })
356 }
357
358 /**
359 * Validation
360 */
361
362 const outputDirName = args._[0]
363 if (outputDirName) {
364 throw Error('The init command does not take any argument.')
365 }
366
367 const { datasourceProvider, url } = await match(args)
368 .with(
369 {
370 '--datasource-provider': P.when((datasourceProvider): datasourceProvider is string =>
371 Boolean(datasourceProvider),
372 ),
373 },
374 (input) => {
375 const datasourceProvider = input['--datasource-provider'].toLowerCase()
376
377 assertDatasourceProvider(datasourceProvider)
378
379 const url = defaultURL(datasourceProvider)
380
381 return { datasourceProvider, url }
382 },
383 )

Callers

nothing calls this directly

Calls 15

helpMethod · 0.95
getTokensMethod · 0.95
writeMethod · 0.95
formatMethod · 0.95
argFunction · 0.90
isErrorFunction · 0.90
canConnectToDatabaseFunction · 0.90
protocolToConnectorTypeFunction · 0.90
loginFunction · 0.90
successMessageFunction · 0.90

Tested by

no test coverage detected