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

Show an arbitrary banner message (Feature request) #78

Closed
rstacruz opened this issue Aug 19, 2012 · 3 comments
Closed

Show an arbitrary banner message (Feature request) #78

rstacruz opened this issue Aug 19, 2012 · 3 comments

Comments

@rstacruz
Copy link

Something like:

require('commander')
  .banner("Output options:")
  .option("-o, --output <path>", "Write to path")
  .option("--debug", "Write debug info to file")
  .banner("Style options:")
  .option("--red", "Choose the red style")
  .option("--blue", "Choose the blue style")
  .option("--green", "Choose the green style")

Expected output:

  Usage: foobar [options]

  Options:

    -h, --help             output usage information
    -V, --version          output the version number

  Output options:

    -o, --output <path>    Write to path
    --debug                Write debug info to file

  Style options:

    --red                  Choose the red style
    --green                Choose the green style
    --blue                 Choose the blue style

aka, "option groups" or "banners" or "messages" (adding this in for anyone searching issues :-) )

@tj
Copy link
Owner

tj commented Aug 19, 2012

sounds reasonable to me ! maybe .title()? label? something like that, .group would work too

@rstacruz
Copy link
Author

I like .label(), but I have no rational reason to argue that. :-)

@thethomaseffect
Copy link
Collaborator

I kind of feel your example would be better served by

option("--style <color>", "Choose a style")

I don't think this is all that bad an idea but I think supplying custom help text is a better idea since that gives you full control over how your stuff is formatted.

Perhaps writing a custom help module that can plug into commander.js that reuses some of the '--help' code but allows you to provide your own formatting and a way to add custom text. Reusing lodash tempting would likely work well. You could pipe it into your build system and have your help text automatically updated but still custom formatted on builds.

Food for thought :)

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

No branches or pull requests

3 participants