diff options
-rw-r--r-- | lib/efl/ecore_getopt.rb | 10 | ||||
-rw-r--r-- | spec/ecore_getopt_spec.rb | 16 |
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/efl/ecore_getopt.rb b/lib/efl/ecore_getopt.rb index 14e5f89..8e07f92 100644 --- a/lib/efl/ecore_getopt.rb +++ b/lib/efl/ecore_getopt.rb @@ -89,7 +89,7 @@ module Efl @ecore_getopt = nil @desc = desc @options = [ - [ 0, FFI::Pointer::NULL, FFI::Pointer::NULL, FFI::Pointer::NULL, 0, {:dummy=>FFI::Pointer::NULL} ] + [ 0 ], ] @values = [ [ :ptrp, FFI::Pointer::NULL ] @@ -120,6 +120,10 @@ module Efl @ecore_getopt[:strict] = @desc[:strict] if @desc.has_key? :strict @options.each_with_index do |o,i| d = @ecore_getopt.desc_ptr i + if o[0]==0 + d[:shortname] = d[:longname] = d[:help] = d[:metavar] = d[:action] = d[:action_param][:dummy] = 0 + break + end d[:shortname] = o[0].to_s.bytes.first d[:longname] = p_from_string o[1] d[:help] = p_from_string o[2] @@ -230,10 +234,10 @@ module Efl def callback_full short, long, help, meta, cb, data, arg_req, def_val self << [ short, long, help, meta, :ecore_getopt_action_callback, [:callback, [cb, data, arg_req, def_val] ] ] end - def callback_noargs short, long, help, cb, data + def callback_noargs short, long, help, cb, data=nil callback_full short, long, help, FFI::Pointer::NULL, cb, data, :ecore_getopt_desc_arg_requirement_no, FFI::Pointer::NULL end - def callback_args short, long, help, meta, cb, data + def callback_args short, long, help, meta, cb, data=nil callback_full short, long, help, meta, cb, data, :ecore_getopt_desc_arg_requirement_yes, FFI::Pointer::NULL end def help short, long diff --git a/spec/ecore_getopt_spec.rb b/spec/ecore_getopt_spec.rb index 9cd95dc..a3c3a30 100644 --- a/spec/ecore_getopt_spec.rb +++ b/spec/ecore_getopt_spec.rb @@ -125,14 +125,14 @@ describe Efl::EcoreGetopt do args = @p.parse ["progname","--version"] @values[:version].read_char.should == 1 end -# it "should handle -H" do -# args = @p.parse ["My lovely prog name","-H"] -# @values[:help].read_char.should == 1 -# end -# it "should handle --help" do -# args = @p.parse ["progname","--help"] -# @values[:help].read_char.should == 1 -# end + it "should handle -H" do + args = @p.parse ["My lovely prog name","-H"] + @values[:help].read_char.should == 1 + end + it "should handle --help" do + args = @p.parse ["progname","--help"] + @values[:help].read_char.should == 1 + end it "should handle -E" do args = @p.parse ["My lovely prog name","-E"] @values[:engines].read_char.should == 1 |