Sha256: f9d2d048e24e04adc63e62ed3155abacd6d3d99875f4dea3b9deadfca19a9276

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

require 'thor'

require_relative '../config'
require_relative 'warner'

module Codeowners
  module Cli
    # Base collects shared methods used by all CLI sub commands
    # It loads and validate the default config file or output an explanation
    # about how to configure it.
    class Base < Thor
      def initialize(args = [], options = {}, config = {})
        super
        @config ||= config[:config] || default_config
        Warner.check_warnings
      end

      private

      attr_reader :config

      def default_config
        Codeowners::Config.new
      end

      def help_stderr
        save_stdout = $stdout
        $stdout = $stderr
        help
        $stdout = save_stdout
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codeowners-checker-1.1.2 lib/codeowners/cli/base.rb
codeowners-checker-1.1.1 lib/codeowners/cli/base.rb