gem and optparse : help needed

Z

Zouplaz

Hello, I want to use optparse on a gem packaged bin/ file
(eg/usr/lib/ruby/gems/1.8/gems/mypackage/bin/foo)

The goal is to make foo usable from the command line without anything
else except the name of the file (no .rb, no ruby ./something)
So, the Ruby file in bin/ directory don't have .rb extension and
includes this as the first line of code
#!/usr/bin/ruby

So does several packages I've seen (rcov for example)

But for a reason I don't understand the code above doesn't works...
From the stdlib doc, tested on a mygem/bin/foo :

#!/usr/bin/ruby
require 'optparse'

options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"

opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end.parse!

p options
p ARGV

foo --verbose
displays
{}
[]


Why ? What's wrong ??

Thanks
 
N

Nobuyoshi Nakada

Hi,

At Fri, 27 Oct 2006 07:30:34 +0900,
Zouplaz wrote in [ruby-talk:222142]:
foo --verbose
displays
{}
[]

It did display {:verbose=>true} as expected.

Does gem's wrapper do something wicked?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

OptParse bug? 4
Stupid optparse question 4
optparse: Arguments as Arguments Unexpectedness 2
array of valid arguments in optparse 1
optparse: parse v. parse! ?? 3
optparse 3
optparse problem 1
Gem help 4

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,109
Latest member
JanieMalco
Top