On Thu, Dec 03, 2020 at 10:26:20AM +0800, Lu Weitao wrote:
[Why] It's more friendly to user that command-line tool have a help option
Signed-off-by: Lu Weitao luweitaobe@163.com
sbin/mail-job | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/sbin/mail-job b/sbin/mail-job index 954c149..85e37a1 100755 --- a/sbin/mail-job +++ b/sbin/mail-job @@ -3,11 +3,32 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. # frozen_string_literal: true
-# Usage: -# mail-job job_id
+require 'optparse' require_relative '../lib/mail_job_result.rb'
Maybe it's better to use absolute paths.
Thanks, Chenglong
-job_id = ARGV[0] +# mail job results to job submitter +# require the job had submitted job.yaml include email
+opt_parser = OptionParser.new do |opts|
- opts.banner = 'Usage: mail-job job_id'
- opts.separator 'eg: mail-job crystal.123012'
- opts.separator ''
- opts.separator 'options:'
- opts.on_tail('-h', '--help', 'show this message') do
- puts opts
- exit
- end
+end
+argv = if ARGV == []
['-h']
else
ARGV
end
+opt_parser.parse!(argv)
+job_id = argv[0] mail = MailJobResult.new(job_id) mail.send_mail -- 2.23.0