Here is an example to replicate the bug, as well as examples of running it, including the output and expected output. Repeatable options don't seem to work with the hash type.
#!/usr/bin/env ruby
# frozen_string_literal: true
require "thor"
class ExampleCLI < Thor
desc "example", "shows how broken things are"
option :doesnt,
:required => false,
:default => {},
:repeatable => true,
:type => :hash,
:desc => "Should be repeatable but isn't"
option :works,
:repeatable => true,
:required => false,
:type => :string
def create()
puts options
end
def self.exit_on_failure?
true
end
end
ExampleCLI.start(ARGV)
You hand in two hashes and expect them to be set as two hashes in an array. What do you get? one hash, not in an array, with all key/vals merged into one hash.
Here is an example to replicate the bug, as well as examples of running it, including the output and expected output. Repeatable options don't seem to work with the hash type.
You hand in two hashes and expect them to be set as two hashes in an array. What do you get? one hash, not in an array, with all key/vals merged into one hash.
Instead, you should end up with an array of two different hashes:
Ordering doesn't seem to matter. It's still broken.
if your keys in your objects are the same, youll end up with one object whos key values are the last ones you handed in.
Instead, you should end up with an array of two different hashes: