[英]Is it possible to have a Thor method that is not an explicit task
我有一个使用多种方法的Thor脚本
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
这可能吗? 如果没有显式任务,则无法正确构建任务列表。
谢谢,
蒂姆
我能够使用no_tasks块。
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
我在2018年试过这个,no_tasks对我不起作用(也许它现在替换为以下内容):
根据Thor的建议
Call desc if you want this method to be available as command or declare it inside a no_commands{} block.
因此,您可以将不希望在CLI中显示的方法放在no_commands块中,如下所示:
# 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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.