How to use thor instead of rake in railtie
Asked Answered
H

1

6

I'd like to provide thor tasks instead of rake tasks in a Railtie. There is a straight forward and well documented way for providing rake scripts in Railties:

class MyRailtie < Rails::Railtie
  rake_tasks do
    load "path/to/my_railtie.tasks"
  end
end  

How can I do the same for thor tasks?

Hyetography answered 16/2, 2012 at 9:50 Comment(0)
O
-1

Thor is just plain 'ol ruby. All you should have to do is make sure the dependency is in your gemspec and then simply require the file from the gem's primary file.

Example:

Your gem's gemspec should contain the following line:

gem.add_dependency :thor

Then, in ./lib/kermit.rb, include the following:

require 'cli'

Then create a file called ./lib/cli.rb and put the thor code in there. Like so:

require 'thor'

class App < Thor
  # Your Code
end
Obvert answered 20/10, 2015 at 4:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.