Class: Fleetctl::Setup::CLI
- Inherits:
-
Object
- Object
- Fleetctl::Setup::CLI
- Defined in:
- lib/fleetctl/setup/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ CLI
constructor
A new instance of CLI.
- #instance_ips ⇒ Object
- #parse_opts! ⇒ Object
Constructor Details
#initialize(argv = ARGV) ⇒ CLI
7 8 9 10 |
# File 'lib/fleetctl/setup/cli.rb', line 7 def initialize(argv=ARGV) = {} @argv = argv end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/fleetctl/setup/cli.rb', line 11 def end |
Instance Method Details
#instance_ips ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fleetctl/setup/cli.rb', line 33 def instance_ips return @instance_ips if @instance_ips results = AWS::Search.search([:search_term]) if results.empty? warn "No stack results found for '#{options[:search_term]}'" exit 1 end choice = user_choice(results) warn "Looking up instances for #{choice.description}" @instance_ips = choice.instances.map(&:public_ip_address).compact return @instance_ips end |
#parse_opts! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fleetctl/setup/cli.rb', line 13 def parse_opts! opt_parser = OptionParser.new do |opts| opts. = "Usage: fleetctl-setup [search-term]" opts.on_tail '-h', '--help', 'show this message' do warn opts exit end end opt_parser.parse!(@argv) if @argv.empty? warn "ERROR: You must supply a keyword or ID to pick a cluster.\n\n" puts opt_parser exit end [:search_term] = @argv.join(' ') .freeze end |