Sha256: ecf658b312807dd1f1ac5457a4ec43a0bf3bfdc20010810e3d98326079f8c337
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
#!/usr/bin/env ruby $:.unshift File.join(File.dirname(__FILE__), '../lib') require 'logger' require 'optparse' require 'yq' $stdout.sync = $stderr.sync = true unless defined?(LOGGER) LOGGER = Logger.new($stderr) end LOGGER.level = Logger::INFO @options = { context: :main_loop } def prereqs ARGV << '--help' if ARGV.empty? opts = OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($0)}" opts.separator '' opts.on_tail('-h', '--help', 'Show this message') do puts opts exit 0 end opts.on('--verbose', '-v', 'verbose') do LOGGER.level = Logger::DEBUG end opts.on("--develop", "Run in developer mode") do @options[:context] = :develop end end opts.parse! required_vars = %w[ ] required_vars.each do |v| raise "#{v} must be specified in the environment variables" unless ENV[v] end end def start begin @yaml = $stdin.read puts Yq.search_yaml(ARGV[0], @yaml) rescue => e LOGGER.error "Unhandled exception #{e.class}: #{e.message}" e.backtrace.each do |v| LOGGER.debug v end raise end end def develop require 'pry' LOGGER.level = Logger::DEBUG LOGGER.info "Develop mode" start binding.pry end def main_loop start end prereqs self.send(@options[:context])
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yq-0.0.1 | bin/yq |