background: follow doc/code_spec.md, command line tool should support help output
Signed-off-by: Lu Weitao luweitaobe@163.com --- sbin/result2stats | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/sbin/result2stats b/sbin/result2stats index 85d68a7..d24cc7b 100755 --- a/sbin/result2stats +++ b/sbin/result2stats @@ -5,6 +5,7 @@
CCI_SRC = File.dirname(__dir__)
+require 'optparse' require "#{CCI_SRC}/lib/matrix2"
File.umask 0o002 @@ -16,6 +17,26 @@ def extract_stats(result_root) system job_script, 'extract_stats' end
-result_root = ARGV[0] || ENV['RESULT_ROOT'] +opt_parser = OptionParser.new do |opts| + opts.banner = 'Usage: result2stats result_root' + opts.separator 'eg: result2stats /srv/result/iperf/crystal.69948' + 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) + +result_root = argv[0] || ENV['RESULT_ROOT'] extract_stats result_root create_stats result_root