davetron5000 / gli

Make awesome command-line applications the easy way
http://davetron5000.github.io/gli
Apache License 2.0
1.26k stars 102 forks source link

:must_match doesn't work with arrays within commands #197

Closed lazee closed 10 years ago

lazee commented 10 years ago

:must_match only works on arrays with 1 element within commands it seems(?). If more elements then it seems like everything is ok from the matchers perspective.

App flag that will work. If file is anything but foo or bar, then I will get an argument error.

flag :f,:file, :desc => c.bold + 'Path to the data.xml file' + c.clear, :arg_name => 'file', :default_value => './data.xml', :must_match => %w{foo bar}

This doesn't work within a command:

desc 'List tags'
command :tags do |c|
  c.flag :format, :desc => 'Output format', :default_value => 'table', :must_match => %w{csv table json}
  c.action do |global_options,options,args|
    formatter = output_formats[options[:format]]
    formatter.formatTags(dataObject.tags)
  end
end

Here GLI will accept any format I type.

lazee commented 10 years ago

Sorry! I had another bug in my test :( Next time I will not be this trigger happy :)