Search code examples
ruby-on-railsrubythor

Is it possible to have a Thor method that is not an explicit task


I have a Thor script that uses several methods

class Update < Thor
   desc "do_it", "a simple task"
   def do_it
     puts i_did_it
   end
   
   # no desc here !!!
   def i_did_it
     "I did it"
   end 
end

Is this possible? Without an explicit task, the tasks list can't be built correctly.

Thanks,

Tim


Solution

  • I was able to use the no_tasks block for this.

    class Update < Thor
       desc "do_it", "a simple task"
       def do_it
         puts i_did_it
       end
    
       # no desc here !!!
       no_tasks do
        def i_did_it
          "I did it"
        end
       end 
    end