Skel.rb
Skelton Ruby Script
See - http://www.ruby-doc.org/stdlib-1.9.3/libdoc/getoptlong/rdoc/GetoptLong.html
#!/usr/bin/env ruby require 'getoptlong' # The parameters can be in any order unless ARGV.length >= 0 puts "Usage: skel.rb [-v] [-d] -n<port_no> -u<user_name> -p<password>" exit end host_name = port_no = user_name = password = '' # specify the options we accept and initialize the option parser verbose_flg = false debug_level = 0 opts = GetoptLong.new( [ "--hostname", "-h", GetoptLong::REQUIRED_ARGUMENT ], [ "--port", "-n", GetoptLong::REQUIRED_ARGUMENT ], [ "--username", "-u", GetoptLong::REQUIRED_ARGUMENT ], [ "--pass", "-p", GetoptLong::REQUIRED_ARGUMENT ], [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ], [ "--inc-debug-level", "-d", GetoptLong::NO_ARGUMENT ] [ "--set-debug-level", "-D", GetoptLong::REQUIRED_ARGUMENT ] ) # process the parsed options opts.each do |opt, arg| case opt when '--hostname' host_name = arg when '--port' port_no = arg when '--username' user_name = arg when '--pass' password = arg when '--inc-debug-level' debug_level += 1 when '--set-debug-level' debug_level = int(arg) when '--verbose' verbose_flg = true end end puts "verbose_flg = #{verbose_flg}" puts "debug_level = #{debug_level}"