lib/bundler/alive/cli.rb in bundler-alive-0.1.2 vs lib/bundler/alive/cli.rb in bundler-alive-0.1.3
- old
+ new
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require "bundler/alive"
require "bundler/alive/doctor"
+require "bundler/alive/reportable"
require "thor"
module Bundler
module Alive
@@ -15,23 +16,21 @@
map "--version" => :version
desc "check [DIR]", "Checks the Gemfile.lock"
method_option :gemfile_lock, type: :string, aliases: "-G",
default: "Gemfile.lock"
+ method_option :result, type: :string, aliases: "-r",
+ default: "result.toml"
def check(_dir = Dir.pwd)
- doctor = check_by_doctor
+ extend Reportable
+ report = check_by_doctor
+ report.save_as_file(options[:result])
+ print_report(report)
- if doctor.rate_limit_exceeded_error
- puts "Too many requested! Retry later."
- exit 1
- end
-
- exit 0 if doctor.all_alive
-
- puts "Not alive gems are found!"
- exit 1
+ exit_status = report.result.all_alive? ? 0 : 1
+ exit exit_status
end
desc "version", "Prints the bundler-alive version"
def version
puts "bundler-alive #{VERSION}"
@@ -39,18 +38,15 @@
private
def check_by_doctor
doctor = begin
- Doctor.new(options[:gemfile_lock])
+ Doctor.new(options[:gemfile_lock], options[:result])
rescue Bundler::GemfileLockNotFound
exit 1
end
doctor.diagnose
- doctor.report
- doctor.save_as_file
- doctor
end
end
end
end