Sha256: 1a26ea210a87157d89e1f57f6d20835b99b2e61f5b161d6d468ef719f976a9bf

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

require "rubygems"
require "commander"
require "gems"

module DbMirror
  class CLI
    include Commander::Methods

    def start
      program :name, DbMirror::Cli::NAME
      program :version, DbMirror::Cli::VERSION
      program :description, DbMirror::Cli::DESCRIPTION
      update_gem!

      command :gen do |c|
      end

      command :compare do |c|
      end
    end

    def update_gem!
      info = Gems.info DbMirror::Cli::NAME

      if Gem::Version.new(DbMirror::Cli::VERSION) < Gem::Version.new(info["version"])
        say "You are running the version #{DbMirror::Cli::VERSION} but the brand new #{info["version"]} is available. 🎉"
        if agree("Why don't you update with `gem update #{DbMirror::Cli::VERSION}`? I can run it for you. 💪")
          system("gem update #{DbMirror::Cli::NAME}")
          abort "Nice! I updated myself. Now you can run the command again."
        end
        abort("Good. Just do it yourself then...😒")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
db_mirror-0.0.1 lib/db_mirror.rb