Sha256: 3e9e4b0b5940443dcc7e44b262fe0e8636666e7e3802c997fa2e1f91caa89a99
Contents?: true
Size: 1.06 KB
Versions: 8
Compression:
Stored size: 1.06 KB
Contents
require 'metriksd/config' require 'optparse' module Metriksd class Cli def initialize(argv) @argv = argv.dup end def parse config_file = nil opts = OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($0)} [options]" opts.on("-c", "--config FILE", "Read configuration file") do |v| config_file = v end opts.separator "" opts.separator "Common options:" opts.on_tail("-h", "--help", "Show this message") do puts opts exit(1) end opts.on_tail("--version", "Show version") do puts Metriksd::VERSION exit(0) end end rest = opts.parse(@argv) unless config_file puts "Error: config file must be specified\n\n" puts opts exit(1) end config = Metriksd::Config.new config.load_file(config_file) config.start config.join rescue Interrupt exit(0) ensure if config config.stop config.join end end end end
Version data entries
8 entries across 8 versions & 1 rubygems