开发者

How can one list method_options with thor -T?

When using thor I am used to w开发者_JAVA百科riting 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!


by default class_option are included in the help, while method_options are only shown when help is called for that task...

% diamond_importer help #shows class options as help, and 1 line per task
% diamond_importer help import #shows the class options and method options for the "import" task.

to change this you need to override the #help and/or #task_help methods of thor.rb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜