Webpack-cli: --help output showing subcommands with `--` prefix

Created on 21 Apr 2018  路  12Comments  路  Source: webpack/webpack-cli

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Webpack's --help flag shows the following options:

Initialization:
  --init             Initializes a new webpack configuration or loads a
                     addon if specified                                [boolean]
  --migrate          Migrate your webpack configuration from webpack 1 to
                     webpack 2                                         [boolean]
  --add              Adds a webpack component to your configuration file
                                                                       [boolean]
  --generate-loader  Generates a new webpack loader project            [boolean]
  --generate-plugin  Generates a new webpack plugin project            [boolean]

The bug is that they're prefixed with --, which is not how they're intended to be invoked:

$ webpack --init
...
ERROR in Entry module not found: Error: Can't resolve './src' in '/home/bryan/scratch'

$ webpack init
i INFO For more information and a detailed description of each question, have a look at https://github.com/webpack/webpack-cli/blob/master/INIT.md
i INFO Alternatively, run `webpack(-cli) --help` for usage info.

? Will your application have multiple bundles? (Y/n)

If the current behavior is a bug, please provide the steps to reproduce.

See previous

What is the expected behavior?

Help output should show sub-commands without the -- prefix.

If this is a feature request, what is motivation or use case for changing the behavior?

Please paste the results of webpack-cli info here, and mention other relevant information such as programming language.

位 webpack-cli  info

  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-3970X CPU @ 3.50GHz
  Binaries:
    Node: 9.11.1
    Yarn: 1.6.0
    npm: 5.6.0
  Browsers: {}
  npmPackages:
    webpack:
      wanted: ^4.6.0
      installed: 4.6.0
    webpack-cli:
      wanted: ^2.0.15
      installed: 2.0.15
Bug

Most helpful comment

I think that's going to be difficult to do, as the help output is generated by yargs.

IMO these should be implemented using yargs.command(), instead of yargs.option(), as they _are_ commands, logically. I'll see about putting together a quick PR (I've been doing a bunch of recent yargs work).

All 12 comments

I believe this is an issue with yargs, actually. I ran into it recently on a non-webpack project. I'll see about getting a minimal repro and file an issue over on their repo.

Unable to repro. Not sure what's going on here.

Have you also tried with migrate? To me, it looks like the script is working

The bug isn't with the scripts _themeselves_, it's a problem with the --help output being incorrect. (Running with webpack --migrate doesn't work, but with webpack migrate does).

I'm taking a look into this one if @ematipico isn't already. @ev1stensberg @ematipico feel free to assign this to me.

@bitpshr yes sure, go ahead!

I could not execute --init either, it goes straight to the compilation process. This is actually a "docs" problem since user will try to do that and won't be able to. This can be fixed using the command api from yargs, this is the result i was able to get.

if @bitpshr could not find a solution, i guess i could open a pr with this one.

We should strip the dashes

I think that's going to be difficult to do, as the help output is generated by yargs.

IMO these should be implemented using yargs.command(), instead of yargs.option(), as they _are_ commands, logically. I'll see about putting together a quick PR (I've been doing a bunch of recent yargs work).

I agree with @rossipedia , other than that we are just doing "workarounds", aren't we?

It totally makes sense!

:tada: This issue has been resolved in version 2.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AjayPoshak picture AjayPoshak  路  5Comments

sam-s4s picture sam-s4s  路  5Comments

logo749 picture logo749  路  4Comments

evenstensberg picture evenstensberg  路  5Comments

sumukhah picture sumukhah  路  3Comments