class B12 < Thor
desc "write", "write data into the index"
method_option :methods, :desc => "The methods to call on each RawData", :type => :array
def write(methods)
end
end
When I call the file via
thor b12:write --methods=foo
I get
"write" was called incorrectly. Call as "thor b12:write".
Where’s the problem?
You’ve got a couple things going on here that’ll cause issues.
First, you’re using
methods, which is a keyword in ruby. That’s going to cause all sorts of nonsense. Use something else, likemy_methods.Second, you don’t need to pass
my_methodsinto write. That creates a default option, not a named option. So you’d callthor b12:write fooif you wanted access tomy_methodsin that context.This works if you call it with:
thor b12:write --my_methods=foo