Sha256: 7bac19b2ccfdcba4f9056dae782545029d99886429622c4c473f4380609480d4

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

#! /usr/bin/env ruby

require 'rubygems'
require 'clamp'
require 'highline'
HighLine.color_scheme = HighLine::SampleColorScheme.new

# create fake command instance to use some global args before we start
class PreParser < Clamp::Command
  option ["-v", "--verbose"], :flag, "be verbose"
  option ["-c", "--config"], "CFG_FILE", "path to custom config file"
end

preparser = PreParser.new File.basename($0), {}
begin
  preparser.parse ARGV
rescue
end

# load user's settings
require 'hammer_cli/settings'

CFG_PATH = ['./config/cli_config.yml', '~/.foreman/cli_config.yml', '/etc/foreman/cli_config.yml']

if preparser.config
  CFG_PATH.unshift preparser.config
end

HammerCLI::Settings.load_from_file CFG_PATH

# setup logging
require 'hammer_cli/logger'
logger = Logging.logger['Init']

if preparser.verbose?
  root_logger = Logging.logger.root
  root_logger.appenders = root_logger.appenders << ::Logging.appenders.stderr(:layout => HammerCLI::Logger::COLOR_LAYOUT)
end

# log which config was loaded (now when we have logging)
HammerCLI::Settings.path_history.each do |path|
  logger.info "Configuration from the file #{path} has been loaded"
end

# load hammer core
require 'hammer_cli'

# load modules set in config
modules = HammerCLI::Settings.get(:modules) || []
modules.each do |m|
  begin
    require m
  rescue => e
    logger.error "Error while loading module #{m}"
    handler = HammerCLI::ExceptionHandler.new(:context => {}, :adapter => :base)
    handler.handle_exception(e)
    exit HammerCLI::EX_SOFTWARE
  end
  logger.info "Extension module #{m} loaded"
end

exit HammerCLI::MainCommand.run || HammerCLI::EX_OK

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hammer_cli-0.0.12 bin/hammer
hammer_cli-0.0.11 bin/hammer
hammer_cli-0.0.10 bin/hammer
hammer_cli-0.0.9 bin/hammer
hammer_cli-0.0.8 bin/hammer
hammer_cli-0.0.7 bin/hammer