Sha256: b811c2d9bdcda59bd7d25908aa1fdfd33ef9df3e238fa3bb927d4c2bc50f0b37

Contents?: true

Size: 1.57 KB

Versions: 36

Compression:

Stored size: 1.57 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 = Vagrant::Util::CheckpointClient.instance.result
        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

36 entries across 32 versions & 5 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/commands/version/command.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/version/command.rb
vagrant-unbundled-2.3.3.0 plugins/commands/version/command.rb
vagrant-unbundled-2.3.2.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.19.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.18.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.16.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.14.0 plugins/commands/version/command.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/commands/version/command.rb
vagrant-unbundled-2.2.10.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.9.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.8.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.7.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.6.2 plugins/commands/version/command.rb
vagrant-unbundled-2.2.6.1 plugins/commands/version/command.rb
vagrant-unbundled-2.2.6.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.5.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.4.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.3.0 plugins/commands/version/command.rb
vagrant-unbundled-2.2.2.0 plugins/commands/version/command.rb