commander-rb / commander

The complete solution for Ruby command-line executables
MIT License
822 stars 74 forks source link

Regression: `--help` no longer works anywhere on the command line #94

Closed JosephPecoraro closed 4 years ago

JosephPecoraro commented 4 years ago

Given a sample program:

require 'commander/import'

program :name, 'Name'
program :version, '0.1'
program :description, 'Issue with Global Option parsing.'

command :cmd do |c|
  c.action do
    puts 'Success'
  end
end

Previously you could use the global --help anywhere on the line but now you can't. This used to provide the help for cmd, but no longer does:

$ ruby foo.rb cmd a --help
invalid command. Use --help for more information

Seems like a recent regression.

JosephPecoraro commented 4 years ago

@orien Recent regression due to your changes? I find it extremely useful that I could just add --help at the end of a line to force get the help for the command.

orien commented 4 years ago

Hey @JosephPecoraro, I'm trying to track down a version of Commander where the example works but cannot find one. I've tried several, going back to version 4.4.0. They all seem to give the same result.

invalid command. Use --help for more information

Which version is working for you?

ggilder commented 4 years ago

I'm also having trouble finding a version where that specific example works. The version without argument works, both in the latest version and previous:

$ ruby foo.rb cmd --help

But adding the argument "a" causes the invalid command error at least back to v4.1.

JosephPecoraro commented 4 years ago

Hmm, well I may have been using a super old version of commander... It does seem like this should work though right?