Class: VagrantAwsInfo::Command
- Inherits:
-
Object
- Object
- VagrantAwsInfo::Command
- Defined in:
- lib/vagrant-awsinfo/command.rb
Defined Under Namespace
Classes: Settings
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
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 |
# File 'lib/vagrant-awsinfo/command.rb', line 7 def execute settings = Settings.new settings.machines = [] settings.keys = nil = OptionParser.new do |o| o. = "Return SSH info from an AWS provisioned Vagrant machine" o.on("-m MACHINE", "The machine to query.") do |value| settings.machines << value end o.on("-k KEY", "single value to return.") do |value| settings.keys = value end end settings.machines = ["default"] if settings.machines.empty? argv = () instance_info = Hash[ get_info(settings.machines).map{ |k,v| [k.to_s,v] } ] if settings.keys if instance_info.has_key?(settings.keys) @env.ui.info instance_info[settings.keys].gsub('"', '') else @env.ui.error "[WARNING] - Supplied key was not found" return 1 end else @env.ui.info instance_info.to_json end end |