Sha256: 7352d98dd4397b093d003d16d3df180f8df9737dadc5edf8afa62f9a84e266de
Contents?: true
Size: 1.57 KB
Versions: 4
Compression:
Stored size: 1.57 KB
Contents
# encoding: utf-8 require 'madvertise/boot' require 'mixlib/cli' $0 = File.basename($0) class CLI include Mixlib::CLI option :configfile, short: '-c FILE', long: '--config FILE', description: 'Configuration File to load' option :name, :short => '-n NAME', :long => '--name NAME', :description => 'Process name', :default => $0, :proc => ->(value) { $0 = value } option :environment, :short => '-e ENVIRONMENT', :long => '--environment ENVIRONMENT', :description => "Set the daemon environment", :default => "development", :proc => ->(value) { Env.set(value) } option :debug, :short => '-D', :long => '--debug', :description => "Enable debug output", :boolean => true, :default => false, :proc => ->(value) { $conf.mixin(log_level: :debug) } option :help, :short => '-h', :long => '--help', :description => "Show this message", :on => :tail, :boolean => true, :show_options => true, :exit => 0 def option(name, args) args[:on] ||= :on args[:boolean] ||= false args[:required] ||= false args[:proc] ||= nil args[:show_options] ||= false args[:exit] ||= nil if args.has_key?(:default) config[name.to_sym] = args[:default] end options[name.to_sym] = args end def self.for(cls, &block) cli = new cli.instance_eval(&block) if block_given? cli.parse_options $log.info("cli:initialize", cli.config) $conf.reload! opts = cli.config.merge({ interval: 1, logger: $log, }) cls.new(opts) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
madvertise-ext-0.5.3 | lib/madvertise/cli.rb |
madvertise-ext-0.5.2 | lib/madvertise/cli.rb |
madvertise-ext-0.5.1 | lib/madvertise/cli.rb |
madvertise-ext-0.5.0 | lib/madvertise/cli.rb |