-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How about supporting Thor::CoreExt::HashWithIndifferentAccess#slice
method?
#804
Comments
Thank you but this class is not supposed to be used by users of thor, so if there isn't a reason for thor to use that method, there isn't a reason to add to thor. |
When using For example: # ./thor.rb
require "thor"
class MyCLI < Thor
class_option :foo
desc "hello NAME", "say hello to NAME"
option :from
def hello(name)
puts "Hello #{name}"
puts "options: #{options}"
puts "options.class: #{options.class}"
puts "options.slice('foo'): #{options.slice('foo')}"
puts "options.slice(:foo): #{options.slice(:foo)}"
end
end
MyCLI.start(ARGV) $ ruby ./thor.rb hello world --from=Tokyo --foo=bar
Hello world
options: {"from"=>"Tokyo", "foo"=>"bar"}
options.class: Thor::CoreExt::HashWithIndifferentAccess
options.slice('foo'): {"foo"=>"bar"}
options.slice(:foo): {} Thank you. |
Makes sense. Please send a PR. |
When extracting a part of
options
hash in a Thor command,options.slice(:foo)
does not work as expected.Wouldn't it be more intuitive to support the
Thor::CoreExt::HashWithIndifferentAccess#slice
method?As a side note,
ActiveSupport::HashWithIndifferentAccess
works as expected.I checked with thor v1.2.1 and current main branch.
https://github.com/rails/thor/blob/v1.2.1/lib/thor/core_ext/hash_with_indifferent_access.rb
https://github.com/rails/thor/blob/e4907fdd663d0a1ff51d18eb1827552ee61300a3/lib/thor/core_ext/hash_with_indifferent_access.rb
Thank you. 🌈
The text was updated successfully, but these errors were encountered: