我正在寫Thor的一些rake任務。在這些thor任務中,我指定了一些方法選項來使命令行更加健壯,但是我遇到的問題是thor不能識別我的命令。Thor爲什麼不識別我的命令行選項?
下面是一個例子任務:
module ReverificationTask
class Notifications < Thor
option :bounce_threshold, :aliases => '-bt', :desc => 'Sets bounce rate', :required => true, :type => :numeric
option :num_email, :aliases => '-e', :desc => 'Sets the amount of email', :required => true, :type => :numeric
desc 'resend_to_soft_bounced_emails [BOUNCE_THRESHOLD] [NUM_EMAIL]'
def resend_to_soft_bounced_emails(bounce_rate, amount_of_email)
Reverification::Process.set_amazon_stat_settings(bounce_rate, amount_of_email)
Reverification::Mailer.resend_soft_bounced_notifications
end
end
end
我按照在托爾官方網頁「選項」 WhatisThor,當我運行thor help reverification_task:notifications:resend_to_soft_bounced_emails
它正確地輸出什麼,我會期望在看命令行參數:
Usage:
thor reverification_task:notifications:resend_to_soft_bounced_emails [BOUNCE_THRESHOLD] [NUM_EMAIL] -bt, --bounce-threshold=N -e, --num-email=N
Options:
-bt, --bounce-threshold=N # Sets bounce rate
-e, --num-email=N # Sets the amount of email
當我執行thor reverification_task:notifications:resend_to_soft_bounced_emails -bt 20 -e 2000
這是響應:
No value provided for required options '--bounce-threshold'
這裏有什麼問題?任何幫助將不勝感激。謝謝。