Skip to content
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

Keyword arguments for a command aren't passed correctly to commands that use callbacks #113

Open
jodosha opened this issue Mar 22, 2021 · 0 comments · May be fixed by #136
Open

Keyword arguments for a command aren't passed correctly to commands that use callbacks #113

jodosha opened this issue Mar 22, 2021 · 0 comments · May be fixed by #136

Comments

@jodosha
Copy link
Member

jodosha commented Mar 22, 2021

Describe the bug

Keyword arguments for a command aren't passed correctly to commands that use callbacks.

To Reproduce

I have two gems: hanami-cli that depends on dry-cli, and hanami-rspec that depends on hanami-cli.

The first gem (hanami-cli) defines a command hanami generate slice NAME, which loosely correspond to this implementation:

module Hanami
  module CLI
    module Generate
      class Slice < Command
        argument :name, required: true, desc: "The slice name"

        def call(name: )
          puts "generating slice: #{name}"
        end
      end
    end
  end
end

The second gem (hanami-rspec) hooks into the invocation of hanami generate slice with an after callback.

module Hanami
  module RSpec
    module Generate
      class Slice < Command
        def call(options, **)
          puts "generating slice: #{options[:name]}"
        end
      end
    end
  end
end

Expected behavior

I would have expected that Hanami::RSpec::Generate::Slice#call would have accepted the :name keyword argument. What it does instead, it passes a Hash.

My environment

  • Affects my production application: NO
  • Ruby version: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
  • OS: Darwin out.lan 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant