add output usage add option -h|--help set default option to -h|--help if no options added
Signed-off-by: Luan Shengde shdluan@163.com --- sbin/{build-my-info.rb => build-my-info} | 12 ++++++++++++ 1 file changed, 12 insertions(+) rename sbin/{build-my-info.rb => build-my-info} (78%)
diff --git a/sbin/build-my-info.rb b/sbin/build-my-info similarity index 78% rename from sbin/build-my-info.rb rename to sbin/build-my-info index fd75f51..ca6a1de 100755 --- a/sbin/build-my-info.rb +++ b/sbin/build-my-info @@ -14,6 +14,11 @@ option = { }
options = OptionParser.new do |opts| + opts.banner = "Usage: build-my-info -e email -n name -l lab\n" + + opts.separator '' + opts.separator 'options:' + opts.on('-e email', 'my_email') do |email| option[:my_email] = email end @@ -25,8 +30,15 @@ options = OptionParser.new do |opts| opts.on('-l lab', 'lab') do |lab| option[:lab] = lab end + + opts.on_tail('-h', '--help', 'show this message') do + puts opts + exit + end end
+ARGV << '-h' if ARGV.empty? + options.parse!
build_my_info = BuildMyInfo.new(option[:my_email], option[:my_name], option[:lab])