From c6a6fd34a3fb1b1bc0253d9aaa8970d7fad81598 Mon Sep 17 00:00:00 2001 From: Greg J Preece Date: Wed, 29 May 2019 10:48:38 -0700 Subject: [PATCH] Adding machine-readable output to global-status --- plugins/commands/global-status/command.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/commands/global-status/command.rb b/plugins/commands/global-status/command.rb index da1399c0c..5cfadcc5e 100644 --- a/plugins/commands/global-status/command.rb +++ b/plugins/commands/global-status/command.rb @@ -65,6 +65,17 @@ module VagrantPlugins @env.machine_index.delete(deletable) if deletable end + # Machine-readable (non-formatted) output + @env.ui.machine("metadata", "machine-count", entries.length.to_s); + entries.each do |entry| + opts = { "target" => entry.send(:name).to_s } + @env.ui.machine("machine-id", entry.send(:id).to_s, opts) + @env.ui.machine("provider-name", entry.send(:provider).to_s, opts) + @env.ui.machine("machine-home", entry.send(:vagrantfile_path).to_s, opts) + @env.ui.machine("state", entry.send(:state).to_s, opts) + end + + # Human-readable (table formatted) output total_width = 0 columns.each do |header, method| header = header.ljust(widths[method]) if widths[method]