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
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
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.