Is it possible to create a Thor based Ruby executable that accepts namespaces? To allow, for example, the following from the commandline: ./thorfile greet:formal
Given I have the following thorfile:
#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
class TalkTasks < Thor
namespace "talk"
desc "greet", "says hello"
def greet
puts "Hello!"
end
class Formal < Thor
namespace "talk:formal"
desc "greet", "says a formal hello"
def greet
puts "Good evening!"
end
end
end
TalkTasks.start
This thorfile provides the following tasks (thor -T
):
thor talk:formal:greet # says a formal hello
thor talk:greet # says hello
I can also use thorfile directly as an executable:
./thorfile greet
Which displays:
Hello!
How can I get ./thorfile formal:greet
(or something similar) to execute the greet method in the Formal class, in order to display:
Good evening!