Sha256: 74377a1237751165eb5d27e433972a1e9a4a5e9ba70a985b4abd7019911e73b8

Contents?: true

Size: 1.54 KB

Versions: 26

Compression:

Stored size: 1.54 KB

Contents

require "optparse"

module VagrantPlugins
  module CommandVersion
    class Command < Vagrant.plugin("2", :command)
      def self.synopsis
        "prints current and latest Vagrant version"
      end

      def execute
        opts = OptionParser.new do |o|
          o.banner = "Usage: vagrant version"
        end

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

        # Output the currently installed version instantly.
        @env.ui.output(I18n.t(
          "vagrant.version_current", version: Vagrant::VERSION))
        @env.ui.machine("version-installed", Vagrant::VERSION)

        # Load the latest information
        cp = @env.checkpoint
        if !cp
          @env.ui.output("\n"+I18n.t(
            "vagrant.version_no_checkpoint"))
          return 0
        end

        latest = cp["current_version"]

        # Output latest version
        @env.ui.output(I18n.t(
          "vagrant.version_latest", version: latest))
        @env.ui.machine("version-latest", latest)

        # Determine if its a new version, and if so, output some more
        # information.
        current = Gem::Version.new(Vagrant::VERSION)
        latest  = Gem::Version.new(latest)
        if current >= latest
          @env.ui.success(" \n" + I18n.t(
            "vagrant.version_latest_installed"))
          return 0
        end

        # Out of date! Let the user know how to upgrade.
        @env.ui.output(" \n" + I18n.t(
          "vagrant.version_upgrade_howto", version: latest.to_s))

        0
      end
    end
  end
end

Version data entries

26 entries across 23 versions & 4 rubygems

Version Path
vagrant-unbundled-2.0.1.0 plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/plugins/commands/version/command.rb
vagrant-unbundled-2.0.0.1 plugins/commands/version/command.rb
vagrant-unbundled-1.9.8.1 plugins/commands/version/command.rb
vagrant-unbundled-1.9.7.1 plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/version/command.rb
vagrant-unbundled-1.9.5.1 plugins/commands/version/command.rb
vagrant-unbundled-1.9.1.1 plugins/commands/version/command.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/version/command.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/version/command.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/version/command.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/version/command.rb
vagrant-unbundled-1.8.5.2 plugins/commands/version/command.rb
vagrant-unbundled-1.8.5.1 plugins/commands/version/command.rb
vagrant-unbundled-1.8.4.2 plugins/commands/version/command.rb
vagrant-unbundled-1.8.4.1 plugins/commands/version/command.rb