Skip to content

--help with additional --options gives 'command not found' #97

@robertgates55

Description

@robertgates55

I often find mysql wanting to put --help on the end of a command to see the help text for that command. With commander, if I do that though, I first have to remove any --option options passed or I get 'command not found'

Example:

#!/usr/bin/env ruby

require 'rubygems'
require 'commander'

class MyApplication
  include Commander::Methods
  # include whatever modules you need

  def run
    program :name, 'test'
    program :version, '0.0.1'
    program :description, 'test'

    command :bob do |c|
      c.syntax = 'test bob [options]'
      c.summary = ''
      c.description = ''
      c.example 'description', 'command example'
      c.option '--some-switch', 'Some switch that does something'
      c.action do |args, options|
        # Do something or c.when_called Test::Commands::Bob
      end
    end

    run!
  end
end

MyApplication.new.run if $0 == __FILE__

Results in:

➜  ruby yourfile.rb --some-switch --help
invalid command. Use --help for more information

Is there any way to make this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions