Class: AwsCsshx::Options
- Inherits:
-
Hash
- Object
- Hash
- AwsCsshx::Options
- Defined in:
- lib/aws_csshx/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#orig_args ⇒ Object
readonly
Returns the value of attribute orig_args.
-
#parsed ⇒ Object
readonly
Returns the value of attribute parsed.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #parsed? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/aws_csshx/options.rb', line 7 def initialize(args) super() user_home = ENV['HOME'] @orig_args = args.clone @parsed = false = {} require 'optparse' @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} <file1> <file2> ..." o.separator "" o.separator "AWS Options" [:group] = 'default' o.on( '-g', '--group group1,group2,group3', Array, 'AWS security group name to use for the csshX sessions (comma separated)' ) do |group| [:group] = group end o.on( '-i', '--aws-identity <identity>', 'Use this keyfile as your SSH private key' ) do |identity| [:ec2_private_key] = identity end o.on( '-r', '--aws-region <region>', 'AWS region to query for the csshX sessions (default: us-east-1)' ) do |region| [:aws_region] = region end o.on( '-H', '--hosts x,y,z', Array, 'Additional hosts to add to the group (comma separated)' ) do |server_list| [:additional_servers] = server_list end o.separator "" o.separator "csshX Options" [:login] = 'root' o.on( '-l', '--login <login>', 'User login to use for the csshX sessions (default: root)' ) do |login| [:login] = login end [:csshx_opts] = '' o.on( '-o', '--csshx-opts <csshx_opts>', 'Pass the options listed directly to csshx' ) do |csshx_opts| [:csshx_opts] = csshx_opts end [:iterm2] = false o.on( '-2', '--iterm2', 'Use csshX.iterm instead of csshx' ) do |iterm2| [:iterm2] = true end o.separator "" [:conf] = "#{Etc.getpwuid.dir}/.csshrc" o.on( '-c', '--conf <file>', 'aws_csshX config file (default: .csshrc)' ) do |file| if File.exists?(file) [:conf] = file else raise FileDoesNotExist, "Config file #{file} cannot be found." end end o.on('-V', '--version', "Display version information") do [:version] = true end [:help] = false o.on( '-h', '--help', 'Display this help screen' ) do [:help] = true end o.separator "" o.separator "Examples:" o.separator " Cluster SSH to all machines in the 'utility' security group:" o.separator " #{File.basename($0)} -g utility" o.separator "" end begin @opts.parse!(args) self[:options] = rescue OptionParser::InvalidOption => e self[:invalid_argument] = e. @opts.parse(args, flags={ :delete_invalid_opts => true }) self[:options] = end @parsed = true end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
5 6 7 |
# File 'lib/aws_csshx/options.rb', line 5 def opts @opts end |
#orig_args ⇒ Object (readonly)
Returns the value of attribute orig_args.
5 6 7 |
# File 'lib/aws_csshx/options.rb', line 5 def orig_args @orig_args end |
#parsed ⇒ Object (readonly)
Returns the value of attribute parsed.
5 6 7 |
# File 'lib/aws_csshx/options.rb', line 5 def parsed @parsed end |
Instance Method Details
#parsed? ⇒ Boolean
97 98 99 |
# File 'lib/aws_csshx/options.rb', line 97 def parsed? @parsed end |