Reputation: 1473
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
Upvotes: 5
Views: 2216
Reputation: 8568
I tried this in 2018, no_tasks didn't work for me (maybe it is replaced with the following now):
As per Thor advice
Call desc if you want this method to be available as command or declare it inside a no_commands{} block.
So you can put the methods that you don't want to show for the CLI in a no_commands block as follows:
# no_commands is used to not show this as a command in our CLI gem
no_commands {
# no desc here !!!
# put here the methods that you don't want to show in your CLI
def i_did_it
"I did it"
end
}
Upvotes: 2
Reputation: 1473
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
Upvotes: 6