#!/usr/bin/env ruby # frozen_string_literal: true lib = File.expand_path('../lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pg_export' begin config = PgExport::ConfigurationParser.parse pg_export = PgExport.new(config) result = pg_export.call result .on_success { |outcome| puts outcome if outcome } .on_failure { |outcome| warn outcome[:message]; exit 1 } rescue PgExport::ConfigurationParser::Error => e warn e.message.capitalize if e.reason == 'missing argument' warn "\nHint for the #{e.args.first} option:" warn PgExport::ConfigurationParser.help.to_s.split("\n").grep(/ #{e.args.first}/).join("\n") end warn 'Type "pg_export -h" to print options.' exit 1 rescue Interrupt puts end