lib/percheron/cli/abstract_command.rb in percheron-0.2.2 vs lib/percheron/cli/abstract_command.rb in percheron-0.2.3

- old
+ new

@@ -1,19 +1,26 @@ module Percheron module CLI class AbstractCommand < Clamp::Command - option [ '-c', '--config_file' ], 'CONFIG', 'Configuration file', default: '.percheron.yml' + DEFAULT_CONFIG_FILE = '.percheron.yml' + option [ '-c', '--config_file' ], 'CONFIG', 'Configuration file', default: DEFAULT_CONFIG_FILE + option '--version', :flag, 'show version' do puts Percheron::VERSION exit(0) end + def default_config_file + ENV.fetch('PERCHERON_CONFIG', DEFAULT_CONFIG_FILE) + end + def config @config ||= Percheron::Config.new(config_file) rescue Errors::ConfigFileInvalid => e - $logger.error "An error has occurred while reading your config file - #{e.message}" + $logger.error e.message + exit(1) end end end end