class SshMenu::Options
Attributes
opts[R]
Public Class Methods
new(args)
click to toggle source
# File lib/sshmenu/options.rb, line 9 def initialize(args) @opts = {} opt_parser = OptionParser.new do |opts| opts.banner = "usage: sshmenu [options] [selected_index]\n" opts.banner << "add no arguments to show a list of configured connections" opts.on('-e', '--edit', 'edit configuration file') do |e| @opts[:action] = :edit end opts.on_tail('-v', '--version', 'print version') do puts "sshmenu, version #{VERSION}" exit end opts.on_tail('-h', '--help', 'print this help') do puts opts exit end end opt_parser.parse!(args) begin @opts[:index] = Integer(args.first) - 1 if args.first rescue ArgumentError raise "'#{args.first}' expected to be a preselected index" end end