Blitz: `blitz db` should print help message instead of error

Created on 1 May 2020  ยท  6Comments  ยท  Source: blitz-js/blitz

command: blitz db

โ€บ Error: Missing 1 required arg:
โ€บ command Run specific db command
โ€บ See more help with --help

the description should be clear to user, that missed command or shows db related command.
such as:
blitz db migrate
blitz db introspect
blitz db studio
etc ....

good first issue kinbug scopcli statudone

Most helpful comment

Screen Shot 2020-05-03 at 05 55 43

I have done it.

All 6 comments

Thank you @nabi009, you're absolutely right!

Happy to work on that if possible ๐Ÿ˜„

@peaonunes yeah, that'd be awesome! Let us know if you need help

Screen Shot 2020-05-03 at 05 55 43

I have done it.

Looks nice! Feel free to open up the PR ๐Ÿ˜„
suggestion: Perhaps we should use log.warning as it is a warning instead of a normal message? Idk. Seems to be missing the reset command, you can interpolate the descriptions static property to be in sync with the command defaults.

@peaonunes thanks so much from your suggestion, your right but I did not change anything too much.
the original code is in /node_modules/@blitzjs/cli/lib/src/commands/db.js
exports.default = Db; Db.description =Run database commands

${chalk_1.default.bold(' migrate')} Run any needed migrations via Prisma 2 and generate Prisma Client.

${chalk_1.default.bold(' introspect')} Will introspect the database defined in db/schema.prisma and automatically \ngenerate a complete schema.prisma file for you. Lastly, it\'ll generate Prisma Client.

${chalk_1.default.bold(' studio')} Open the Prisma Studio UI at http://localhost:5555 so you can easily see and\n change data in your database.
`;

Db.args = [

{
    name: 'Commands',
    description: 'Run specific db command',
    required: true,
},

];

Db.flags = {
help: command_1.flags.help({ char: 'h' }),
};
and I changed it to this exports.default = Db;
Db.description =`Run database

${chalk_1.default.bold('๐Ÿ‘‰ migrate')} Run any needed migrations via Prisma 2 and generate Prisma Client.

${chalk_1.default.bold('๐Ÿ‘‰ introspect')} Will introspect the database defined in db/schema.prisma and automatically \ngenerate a complete schema.prisma file for you. Lastly, it\'ll generate Prisma Client.

${chalk_1.default.bold('๐Ÿ‘‰ studio')} Open the Prisma Studio UI at http://localhost:5555 so you can easily see and\n change data in your database.
`;

Db.args = [

{
    name: 'Commands',
    description: Db.description,
    required: true,
},

];

Db.flags = {
help: command_1.flags.help({ char: 'h' }),
};`

I replace this "Run specific db command' to Db.description.
Screen Shot 2020-05-03 at 05 55 43
now I think gives clear descriptions to the users.

  1. Error: Missing 1 required arg:
  2. tells to the user that you may use these commands after db
    Commands Run database
    โ€บ
    โ€บ ๐Ÿ‘‰ migrate Run any needed migrations via Prisma 2 and generate Prisma Client.
    โ€บ
    โ€บ ๐Ÿ‘‰ introspect Will introspect the database defined in db/schema.prisma and automatically
    โ€บ generate a complete schema.prisma file for you. Lastly, it'll generate Prisma Client.
    โ€บ
    โ€บ ๐Ÿ‘‰ studio Open the Prisma Studio UI at http://localhost:5555 so you can easily see and
    โ€บ change data in your database.
  3. farther you may use --help to get full cli commands help
    See more help with --help
Was this page helpful?
0 / 5 - 0 ratings

Related issues

netheril96 picture netheril96  ยท  4Comments

aaronfulkerson picture aaronfulkerson  ยท  3Comments

eorenstein1 picture eorenstein1  ยท  3Comments

flybayer picture flybayer  ยท  4Comments

svobik7 picture svobik7  ยท  3Comments