bin/yq in yq-0.4.0 vs bin/yq in yq-0.4.1
- old
+ new
@@ -6,13 +6,11 @@
require 'optparse'
require 'yq'
$stdout.sync = $stderr.sync = true
-unless defined?(LOGGER)
- LOGGER = Logger.new($stderr)
-end
+LOGGER = Logger.new($stderr) unless defined?(LOGGER)
LOGGER.level = Logger::INFO
@options = {
context: :main_loop,
output: :yaml
@@ -29,11 +27,11 @@
exit 0
end
opts.on('--verbose', '-v', 'verbose') do
LOGGER.level = Logger::DEBUG
end
- opts.on("--develop", "Run in developer mode") do
+ opts.on('--develop', 'Run in developer mode') do
@options[:context] = :develop
end
opts.on('-r', '--raw-output') do
@options[:output] = :raw
end
@@ -47,39 +45,33 @@
]
required_vars.each do |v|
raise "#{v} must be specified in the environment variables" unless ENV[v]
end
- raise "jq not installed" unless Yq.which('jq')
+ raise 'jq not installed' unless Yq.which('jq')
end
-
def start
- begin
- @yaml = $stdin.read
+ @yaml = $stdin.read
- puts Yq.search_yaml(ARGV[0], @yaml, output: @options[:output])
-
- rescue => e
- LOGGER.error "Unhandled exception #{e.class}: #{e.message}"
- e.backtrace.each do |v|
- LOGGER.debug v
- end
- raise
+ puts Yq.search_yaml(ARGV[0], @yaml, output: @options[:output])
+rescue StandardError => e
+ LOGGER.error "Unhandled exception #{e.class}: #{e.message}"
+ e.backtrace.each do |v|
+ LOGGER.debug v
end
-
+ raise
end
def develop
require 'pry'
LOGGER.level = Logger::DEBUG
- LOGGER.info "Develop mode"
+ LOGGER.info 'Develop mode'
start
end
def main_loop
start
end
-
prereqs
-self.send(@options[:context])
+send(@options[:context])