Ruby Thor based executable with namespaces -


is possible create thor based ruby executable accepts namespaces? allow, example, following commandline: ./thorfile greet:formal

given have 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 formal hello"     def greet       puts "good evening!"     end   end  end  talktasks.start 

this thorfile provides following tasks (thor -t):

thor talk:formal:greet  # says formal hello thor talk:greet         # says hello 

i can use thorfile directly executable:

./thorfile greet 

which displays:

hello!

how can ./thorfile formal:greet (or similar) execute greet method in formal class, in order display:

good evening!

change namespace formal class

class formal < thor     namespace "formal"     ... end 

you have nested classes namespaces nest. if separate them can talk:formal hehe no time test it. should work.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -