2011-06-28 19 views
2

當使用托爾我習慣這樣寫代碼,如何使用thor -T列出method_options?

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」之類的選項或其用法的描述。

如何添加這些使用細節以便它們能夠顯示?

謝謝!

回答

2

默認class_option包括在幫助,而當幫助稱爲該任務只能顯示method_options ...

% 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. 

改變這一點,你需要重寫#幫助和/或#task_help thor.rb的方法