I expected all values of my type: array option to also be validated.
Example
cli.rb:
require "thor"
class MyCLI < Thor
desc "array_with_enum [--fruits=apple banana]", "Demo of using an enum with an array"
option :fruits, type: :array, enum: ["apple", "banana", "clementine"]
def array_with_enum
puts "fruits: #{options[:fruits]}"
end
end
MyCLI.start(ARGV)
This works:
ruby ./cli.rb array_with_enum --fruits=banana apple
fruits: ["banana", "apple"]
🌈
enum
was added in https://github.com/rails/thor/pull/237, but it originally only validatedtype: string
values.Validation of
type: numeric
values was added in https://github.com/rails/thor/pull/386I expected all values of my
type: array
option to also be validated.Example
cli.rb
:This works:
This also works:
but shouldn't since "kiwi" is not a fruit in the
enum
.