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
6 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 |
# File 'lib/vagrant-awsinfo/command.rb', line 6 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 o.on("-p", "Pretty print values.") do |value| settings.pretty = true end end argv = () settings.machines = ["default"] if settings.machines.empty? #@env.ui.debug "[vagrant-awsinfo] - Getting info for machine " + settings.machines.inspect 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 if settings.pretty jj instance_info else @env.ui.info instance_info.to_json end end end |