Sha256: c9393bb48984e02a7f6cb212f974ff002f408e576ab5a71d154feb6457c12486

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require "bundler/alive"
require "bundler/alive/doctor"
require "bundler/alive/reportable"

require "thor"

module Bundler
  module Alive
    #
    # The `bundler-alive` command.
    #
    class CLI < ::Thor
      default_task :check
      map "--version" => :version

      desc "check [DIR]", "Checks the Gemfile.lock"
      method_option :ignore, type: :array, aliases: "-i", default: []
      method_option :gemfile_lock, type: :string, aliases: "-G",
                                   default: "Gemfile.lock"
      method_option :config, type: :string, aliases: "-c", default: ".bundler-alive.yml"

      def check(_dir = Dir.pwd)
        extend Reportable
        report = check_by_doctor
        print_report(report)

        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}"
      end

      private

      def check_by_doctor
        doctor = initialize_doctor

        begin
          doctor.diagnose
        rescue Bundler::Alive::Client::GitlabApi::AccessTokenNotFoundError => e
          say "\n#{e.message}", :yellow
          exit 1
        end
      end

      def initialize_doctor
        Doctor.new(options[:gemfile_lock], options[:config], options[:ignore])
      rescue Bundler::GemfileLockNotFound
        exit 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bundler-alive-0.1.6 lib/bundler/alive/cli.rb