[英]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.