Sha256: 9699693fac68159529aacb46008848d2bb52b39868353552dbd4f1d1de246b99

Contents?: true

Size: 899 Bytes

Versions: 2

Compression:

Stored size: 899 Bytes

Contents

require "json"
require "open-uri"
require "thor"

module Dogids
  VERSION = "0.0.17"

  class Cli < Thor
    desc "update", "Update dogids-cli to latest version"
    def update
      command = "gem install dogids-cli"
      puts "Running #{command}"
      exec(command)
    end

    desc "version", "Show version information"
    def version
      gem_version = "v#{Dogids::VERSION}"

      # Grab the latest version of the RubyGem
      rubygems_json = open("https://rubygems.org/api/v1/gems/dogids-cli.json").read
      rubygems_version = "v#{JSON.parse(rubygems_json)['version'].strip}"

      upgrade_message = ""
      if gem_version != rubygems_version
        upgrade_message = " Run `dogids update` to install"
      end

      puts
      puts "Dogids CLI"
      puts "  Installed: #{gem_version}"
      puts "  Latest:    #{rubygems_version}#{upgrade_message}"
      puts
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dogids-cli-0.0.18 lib/dogids/version.rb
dogids-cli-0.0.17 lib/dogids/version.rb