Take the 2-minute tour ×

I've just started using Thor. I've been looking around the documentation and can't find any code examples of making a task hidden. What I want is something like this,

desc "configure", "Do the configuration"
def configure
  # configuration

desc "import", "Import the stuff"
  invoke :configure
  # import the stuff

But I don't want configure to show up in the list of tasks. It's kind of... private, you know? Can someone give me an example of this?

In lib/thor/task.rb there is a subclass of Task called HiddenTask. Can anyone provide an example of how that subclass is used, and of how its method hidden? gets called? Thanks!

EDIT: Both of the answers below accomplish the goal mentioned in my question, but neither of them are an example of Thor:HiddenTask usage. I think I'm going to un-accept the answer to this question. They are both good answers, and the first one I actually used to achieve the desired behavior, but I would really like to see an example of a HiddenTask so that the answer corresponds to the question nicely.


share|improve this question

2 Answers 2

up vote 5 down vote accepted

In thor/spec/fixtures/script.thor you can find such usage:

desc "hidden TYPE", "this is hidden", :hide => true
def hidden(type)
share|improve this answer

This is a little late but maybe this can help. Put your private methods in a "no_task" block like:

no_task do
  def my_private_method
    # Do something here
share|improve this answer
This is the solution that I used to make my sweet app work, but it isn't an example of HiddenTask. This answer was originally marked as the accepted answer. –  Ziggy Aug 4 '11 at 19:22

Your Answer


