tj / commander

The complete solution for Ruby command-line executables
http://visionmedia.github.com/commander
MIT License
1.09k stars 64 forks source link

--help should display the command flags/options of the default command #89

Closed KrauseFx closed 9 years ago

KrauseFx commented 9 years ago

I use the following code

    command :run do |c|
      c.syntax = 'deliver'
      c.description = 'Run a deploy process using the Deliverfile in the current folder'
      c.option '--force', 'Runs a deployment without verifying any information (PDF file). This can be used for build servers.'
      c.option '--beta', 'Runs a deployment to beta build on iTunes Connect'
      c.option '--skip-deploy', 'Skips deployment on iTunes Connect'
      c.action do |args, options|
        ...
      end
    end

    default_command :run

When running deliver --help, it will only show the global options (which probably makes sense in some use cases), but I'd prefer to display the options for the default command.

KrauseFx commented 9 years ago

I switched to using global_option instead, but that's not 100% correct, since I also have a second command deliver init, which is used only once for setting up the tool.

ggilder commented 9 years ago

I could see that as a possible enhancement but I'm not sure it should be default behavior. If you'd like to put together a pull request for that we can definitely add it!