Class: Vagrant::Json::Command
- Inherits:
-
Object
- Object
- Vagrant::Json::Command
- Defined in:
- lib/vagrant-json/command.rb
Instance Method Summary collapse
-
#execute ⇒ Object
Executes this command.
Instance Method Details
#execute ⇒ Object
Executes this command.
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-json/command.rb', line 9 def execute = {} opts = OptionParser.new do |opt| opt. = 'Usage: vagrant json-status' opt.separator '' opt.on('--pretty', 'Pretty print JSON.') do |p| [:pretty] = true end end # Parse any commandline options argv = (opts) return unless argv entries = { machines: {} } # Get all vagrant machines @env.machine_index.each do |entry| entries[:machines][entry.id] = { name: entry.name, provider: entry.provider, state: entry.state, directory: entry.vagrantfile_path } end @env.ui.info ([:pretty] ? JSON.pretty_generate(entries) : JSON.generate(entries)) 0 end |