require 'thor' module Gemdiff class CLI < Thor include Colorize default_task :outdated CHECKING_FOR_OUTDATED = "Checking for outdated gems in your bundle..." desc 'find ', 'Find the github repository URL for a gem' def find(gem_name) gem = OutdatedGem.new(gem_name) if gem.repo? puts gem.repo else puts "Could not find github repository for #{gem_name}." end gem end desc 'open ', 'Open the github repository for a gem' def open(gem_name) gem = find(gem_name) gem.open end desc 'releases ', 'Open the github releases page for a gem' def releases(gem_name) gem = find(gem_name) gem.releases end desc 'commits ', 'Open the github master branch commits page for a gem' def commits(gem_name) gem = find(gem_name) gem.commits end desc 'compare [...]', <', 'Update a gem, show a git diff of the update, and commit or reset' def update(name) puts "Updating #{name}..." gem = GemUpdater.new(name) gem.update puts colorize_git_output(gem.diff) response = ask("\nCommit? (c to commit, r to reset, else do nothing)") if response == 'c' gem.commit puts "\n" + colorize_git_output(gem.show) elsif response == 'r' puts gem.reset end end end end