Module: Matchd::CLI::ConfigFileOption

Included in:
Main
Defined in:
lib/matchd/cli/config_file_option.rb

Overview

A little patch to allow a “class_option” for letting Matchd be configured using the given or default config file

Class Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/matchd/cli/config_file_option.rb', line 5

def self.included(receiver)
  receiver.class_exec do
    class_option :config,
      type: :string,
      aliases: "-c",
      group: :runtime,
      default: Matchd::Config::DEFAULT_CONFIG_FILE,
      desc: "The config file to read"

    no_commands do
      def initialize(args = [], local_options = {}, config = {})
        super
        Matchd.configure_from_file!(options[:config]) if File.file?(options[:config])
      end
    end
  end
end