| 32 | private constructor(private readonly cmds: Commands) {} |
| 33 | |
| 34 | public async parse(argv: string[], config: PrismaConfigInternal, baseDir: string): Promise<string | Error> { |
| 35 | const args = arg(argv, { |
| 36 | '--help': Boolean, |
| 37 | '-h': '--help', |
| 38 | '--telemetry-information': String, |
| 39 | }) |
| 40 | |
| 41 | if (isError(args)) { |
| 42 | return this.help(args.message) |
| 43 | } |
| 44 | |
| 45 | if (args._.length === 0 || args['--help']) { |
| 46 | return this.help() |
| 47 | } |
| 48 | |
| 49 | const cmd = this.cmds[args._[0]] |
| 50 | if (cmd) { |
| 51 | return cmd.parse(args._.slice(1), config, baseDir) |
| 52 | } |
| 53 | |
| 54 | return unknownCommand(PostgresCommand.help, args._[0]) |
| 55 | } |
| 56 | |
| 57 | public help(error?: string): string | HelpError { |
| 58 | if (error) { |