如何使用 thor -T 列出 method_options?
当使用 thor 时,我习惯于编写这样的代码,
desc "import", "Import diamonds from the south."
method_option :num_diamonds, :type => :numeric, :default => nil
def import
diamond_importer = DiamondImporter.new
diamond_importer.update_maps
diamond_importer.process_diamonds(options)
end
当我运行不带参数的 Diamond_importer 命令行工具或使用 -TI 时,会获取“导入”等任务的描述列表,但不会获取“num_diamonds”等选项的描述”或它们的用法。
如何添加此类使用详细信息以便显示它们?
谢谢!
When using thor I am used to writing code like this,
desc "import", "Import diamonds from the south."
method_option :num_diamonds, :type => :numeric, :default => nil
def import
diamond_importer = DiamondImporter.new
diamond_importer.update_maps
diamond_importer.process_diamonds(options)
end
When I run the diamond_importer command-line tool with no arguments, or with a -T I get a list of descriptions of tasks like "import", but not description of options like "num_diamonds" or their usage.
How can I add such usage details so that they will be displayed?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,class_option 包含在帮助中,而 method_options 仅在为该任务调用帮助时显示...
要更改此设置,您需要覆盖 thor.rb 的 #help 和/或 #task_help 方法
by default class_option are included in the help, while method_options are only shown when help is called for that task...
to change this you need to override the #help and/or #task_help methods of thor.rb