Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show commands with --help #719

Merged
merged 1 commit into from
Dec 1, 2018

Conversation

flandrade
Copy link
Contributor

Fixes #707

Issue

When --help or version are provided, yargs exit the process before loading the commands and the view helper.

Output with --help:

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                            [boolean]

Output with --version:

5.3.0

Solution

Add exitProcess(false) so the process doesn't exit before loading the commands. In addition, help and version are also disable so they don't get printed when loading yargs.

help and version are enabled when loading the modules.

Output with --help:

Sequelize CLI [Node: 10.13.0, CLI: 5.3.0, ORM: 4.41.0]

sequelize [command]

Commands:
  sequelize db:migrate                        Run pending migrations
  sequelize db:migrate:schema:timestamps:add  Update migration table to have timestamps
  sequelize db:migrate:status                 List the status of all migrations
  sequelize db:migrate:undo                   Reverts a migration
  sequelize db:migrate:undo:all               Revert all migrations ran
  sequelize db:seed                           Run specified seeder
  sequelize db:seed:undo                      Deletes data from the database
  sequelize db:seed:all                       Run every seeder
  sequelize db:seed:undo:all                  Deletes data from the database
  sequelize db:create                         Create database specified by configuration
  sequelize db:drop                           Drop database specified by configuration
  sequelize init                              Initializes project
  sequelize init:config                       Initializes configuration
  sequelize init:migrations                   Initializes migrations
  sequelize init:models                       Initializes models
  sequelize init:seeders                      Initializes seeders
  sequelize migration:generate                Generates a new migration file                                                       [aliases: migration:create]
  sequelize model:generate                    Generates a model and its migration                                                      [aliases: model:create]
  sequelize seed:generate                     Generates a new seed file                                                                 [aliases: seed:create]

Options:
  --help     Show help                                                                                                                               [boolean]
  --version  Show version number                                                                                                                     [boolean]

Output with --version:

Sequelize CLI [Node: 10.13.0, CLI: 5.3.0, ORM: 4.41.0]

5.3.0

Other changes

  • Since version 9.0, yargs are enabled by default, so it's not required to add help() to each command. See yargs' changelog.

@flandrade flandrade force-pushed the fix-cli-help-and-version branch 2 times, most recently from 32c5cde to 902091c Compare November 26, 2018 01:57
@flandrade flandrade force-pushed the fix-cli-help-and-version branch from 902091c to 8611590 Compare November 26, 2018 19:45
@sushantdhiman
Copy link
Contributor

Can you show output for sequelize db:migrate --help

@sushantdhiman
Copy link
Contributor

Seems to work well, thanks @flandrade

sequelize db:migrate --help

Sequelize CLI [Node: 8.11.3, CLI: 5.3.0, ORM: 4.39.0]

Options:
  --help             Show help                                                                                                              [boolean]
  --version          Show version number                                                                                                    [boolean]
  --env              The environment to run the command in                                                          [string] [default: "development"]
  --config           The path to the config file                                                                                             [string]
  --options-path     The path to a JSON file with additional options                                                                         [string]
  --migrations-path  The path to the migrations folder                                                               [string] [default: "migrations"]
  --seeders-path     The path to the seeders folder                                                                     [string] [default: "seeders"]
  --models-path      The path to the models folder                                                                       [string] [default: "models"]
  --url              The database connection string to use. Alternative to using --config files                                              [string]
  --debug            When available show various debug information                                                         [boolean] [default: false]
  --to               Migration name to run migrations until                                                                                  [string]
  --from             Migration name to start migrations from (excluding)                                                                     [string]

@sushantdhiman sushantdhiman merged commit 55a8673 into sequelize:master Dec 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants