tj / commander

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

-- #34

Closed dvv closed 12 years ago

dvv commented 12 years ago

Hi!

Please, consider supporting '--'. Any stuff after '--' should go to arguments, even if it looks like an option

TIA, --Vladimir

tj commented 12 years ago

yup! we have an issue open for this, thanks man

tj commented 12 years ago

doh! I thought this was commander.js haha... my bad

ggilder commented 12 years ago

@visionmedia Hehe, that's what you get for making an awesome library twice ;)

@dvv I believe we actually already support '--' because it's built into the OptionParser library on which commander is based.

Here's an example program to demonstrate:

#!/usr/bin/env ruby

require 'rubygems'
require 'commander/import'

program :version, '0.1'
program :description, 'Test'

command :foo do |c|
  c.syntax = 'Test foo [options]'
  c.option '-x', 'Switch'
  c.action do |args, options|
    say "Arguments:"
    say args.inspect
    say "Options:"
    say options.inspect
  end
end

And the results of calling it with/without a double-dash argument:

$ ruby test.rb foo -x
Arguments:
[]
Options:
<Commander::Command::Options x=true>

$ ruby test.rb foo -- -x
Arguments:
["-x"]
Options:
<Commander::Command::Options >

So it seems like it behaves as expected. If you're seeing an issue using the double-dash, please provide example code that triggers the problem so we can diagnose.

Thanks!

dvv commented 12 years ago

Hehe. Indeed, it should go to visionmedia/commander.js

tj commented 12 years ago

@dvv just added this to commander.js