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

start-storybook cli flag conflict #5360

Closed
pascalduez opened this issue Jan 24, 2019 · 8 comments · Fixed by #5464
Closed

start-storybook cli flag conflict #5360

pascalduez opened this issue Jan 24, 2019 · 8 comments · Fixed by #5464
Assignees

Comments

@pascalduez
Copy link
Contributor

pascalduez commented Jan 24, 2019

Describe the bug

The start-storybook cli make use of the shorthand -h flag for two different functions.
host and help, host overriding help.
The help flag is automatically inserted by the commander package.
No big deal, but could be a quick-win.

➜ ./node_modules/.bin/start-storybook --help                                                                                                  
Usage: start-storybook [options]                                                                                                              
                                                                                                                                              
Options:                                                                                                                                      
  -V, --version                 output the version number                                                                                     
  -p, --port [number]           Port to run Storybook                                                                                         
  -h, --host [string]           Host to run Storybook                                                                                         
  -s, --static-dir <dir-names>  Directory where to load static files from                                                                     
  -c, --config-dir [dir-name]   Directory where to load Storybook configurations from                                                         
  --https                       Serve Storybook over HTTPS. Note: You must provide your own certificate information.                          
  --ssl-ca <ca>                 Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)    
  --ssl-cert <cert>             Provide an SSL certificate. (Required with --https)                                                           
  --ssl-key <key>               Provide an SSL key. (Required with --https)                                                                   
  --smoke-test                  Exit after successful start                                                                                   
  --ci                          CI mode (skip interactive prompts, don't open browser                                                         
  --quiet                       Suppress verbose build output                                                                                 
  -h, --help                    output usage information                                                                                      
@Keraito
Copy link
Contributor

Keraito commented Jan 25, 2019

Thanks for the catch @pascalduez! I'm not quite sure though whether it's just as easy as changing the -h flag for host, as it maybe will cause breaking changes/backwards compatibility issues for the CLI. Perhaps we can uppercase the help flag to -H instead in that case? WDYT @shilman?

@shilman
Copy link
Member

shilman commented Jan 26, 2019

That sounds like a good workaround to me @Keraito!

@Keraito
Copy link
Contributor

Keraito commented Jan 26, 2019

@pascalduez would you like to open a PR for it? 😊

@pascalduez
Copy link
Contributor Author

I was thinking of just removing the -h shorthand for --help, lots of cli tools don't have it.
I had a quick look but not sure whether commander is going to make it easy or not.

Tell me the desired solution and I'll open a PR.

@Keraito
Copy link
Contributor

Keraito commented Jan 27, 2019

I had a quick look but not sure whether commander is going to make it easy or not.

@pascalduez Let's just stick to uppercasing the -h flag for help to -H. There's no harm in keeping it around and personally I'm used to having it as well. Also seems like the easiest solution for now.

@pascalduez
Copy link
Contributor Author

I don't think it's currently possible to change the -h, --help flags from commander, it's hardcoded all over the place.

See tj/commander.js#893

There's a little hack we could apply, so that calling start-storybook -h with no value will output the help:

program.on('option:host', value => {
  if (!value) {
    program.help();
  }
});

@Keraito
Copy link
Contributor

Keraito commented Feb 3, 2019

That sounds like a decent workaround for now @pascalduez

@shadowspawn
Copy link

For your interest, from Commander v3, there is .helpOption to customise the help flags and message: https://github.com/tj/commander.js/releases/tag/v3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants