Sha256: 33f31943231e05dd4d3338d6ad66a42a46a0f7ade9258e1de87237bae293583a
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'ostruct' require 'cli_spinnable' require 'pg_export' require 'pg_export/includable_modules/colourable_string' require 'pg_export/includable_modules/interactive' config = PgExport::ServicesContainer.config pg_export = PgExport.new option_parser = OptionParser.new do |opts| opts.banner = 'Usage: pg_export [options]' opts.on('-d', '--database DATABASE', '[Required] Name of the database to export') do |database| config.database = database end opts.on('-k', '--keep [KEEP]', Integer, "[Optional] Number of dump files to keep on FTP (default: #{config.keep_dumps})") do |keep| config.keep_dumps = keep end opts.on('-t', '--timestamped', '[Optional] Enables log messages with timestamps') do PgExport::Logging.format_timestamped end opts.on('-i', '--interactive', 'Interactive, command line mode, for restoring dumps into databases') do PgExport::Logging.mute config.database ||= 'undefined' pg_export.extend(PgExport::Interactive) end opts.on('-h', '--help', 'Show this message') do puts opts exit end opts.separator "\nSetting can be verified by running following commands:" opts.on('-c', '--configuration', 'Prints the configuration') do puts config.to_s exit end opts.on('-f', '--ftp', 'Tries connecting to FTP to verify the connection') do PgExport::ServicesContainer.ftp_connection.open exit end end begin option_parser.parse! pg_export.call rescue OptionParser::MissingArgument, PgExport::InvalidConfigurationError => e using PgExport::ColourableString puts "Error: #{e}".red puts option_parser rescue PgExport::PgDumpError => e puts e end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pg_export-0.5.1 | bin/pg_export |
pg_export-0.5.0 | bin/pg_export |