Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Thor 0.16 breaks on invokes with different argument counts #286

mperham opened this Issue Nov 25, 2012 · 1 comment


None yet
2 participants

mperham commented Nov 25, 2012

class Inventory < Thor
  include Thor::Actions

  desc "process_csv FILE", "process the nightly inventory update"
  method_option :delete, :aliases => "-d", :desc => "Delete the file after parsing it"
  def process_csv(file)
    invoke :rails
    #require 'inventory_file'
    remove_file(file) if options[:delete]

  desc 'rails', 'boot the rails environment'
  def rails
    require './config/environment'
> thor inventory:process_csv foo.csv
thor rails requires at least 0 argument: "thor inventory:rails".

larrylv commented Dec 10, 2012

I think that's a default behavior of :invoke, not a break.

As you can see here: https://github.com/wycats/thor/blob/master/lib/thor/invocation.rb#L64

    # When class A invokes class B, all arguments used on A initialization are
    # supplied to B.

, and here: https://github.com/wycats/thor/blob/master/lib/thor/invocation.rb#L87

    # If you want Rspec::RR to be initialized with its own set of options, you
    # have to do that explicitly:
    # invoke "rspec:rr", [], :style => :foo

So in your case, you should do this:

  def process_csv(file)
    invoke :rails, [], {}
    #require 'inventory_file'
    remove_file(file) if options[:delete]

@mperham mperham closed this Dec 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment