Sha256: c1729f00b3533e02e300c02cb5928b9e1057cc126f0b64a58b6cf8fd7b77b097

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 KB

Contents

require 'optparse'

module VagrantPlugins
  module CommandBox
    module Command
      class List < Vagrant.plugin("2", :command)
        def execute
          options = {}

          opts = OptionParser.new do |opts|
            opts.banner = "Usage: vagrant box list"
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv

          boxes = @env.boxes.all.sort
          if boxes.empty?
            return @env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), :prefix => false)
          end

          # Find the longest box name
          longest_box = boxes.max_by { |x| x[0].length }
          longest_box_length = longest_box[0].length

          # Go through each box and output the information about it. We
          # ignore the "v1" param for now since I'm not yet sure if its
          # important for the user to know what boxes need to be upgraded
          # and which don't, since we plan on doing that transparently.
          boxes.each do |name, provider, _v1|
            @env.ui.info("#{name.ljust(longest_box_length)} (#{provider})", :prefix => false)
          end

          # Success, exit status 0
          0
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/list.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/list.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/list.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/box/command/list.rb
tnargav-1.3.6 plugins/commands/box/command/list.rb
tnargav-1.3.3 plugins/commands/box/command/list.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/box/command/list.rb
tnargav-1.2.3 plugins/commands/box/command/list.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/box/command/list.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/box/command/list.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/box/command/list.rb
tnargav-1.2.2 plugins/commands/box/command/list.rb
vagrantup-1.1.3 plugins/commands/box/command/list.rb
vagrantup-1.1.2 plugins/commands/box/command/list.rb
vagrantup-1.1.1 plugins/commands/box/command/list.rb
vagrantup-1.1.0 plugins/commands/box/command/list.rb
vagrantup-1.1.4 plugins/commands/box/command/list.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/plugins/commands/box/command/list.rb
vagrant-lxc-0.0.1 vendor/vagrant/plugins/commands/box/command/list.rb