Sha256: 0912f30181fca385b19908d1a91486d08e33fb9416638119e2cda9035a8588d3
Contents?: true
Size: 1.69 KB
Versions: 5
Compression:
Stored size: 1.69 KB
Contents
#!/usr/bin/env ruby require 'web_translate_it/safe' include WebTranslateIt::Safe def die(msg) puts "ERROR: #{msg}" exit 1 end def usage puts <<~END Usage: webtranslateit-safe [OPTIONS] CONFIG_FILE Options: -h, --help This help screen -v, --verbose be verbose, duh! -n, --dry-run just pretend, don't do anything. -L, --local skip S3 and Cloud Files Note: config file will be created from template if missing END exit 1 end OPTS = [ '-h', '--help', '-v', '--verbose', '--not-verbose', '-n', '--dry-run', '--not-dry-run', '-L', '--local', '--not-local' ].freeze def main # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity opts = ARGV & OPTS args = ARGV - OPTS usage unless args.first usage if opts.delete('-h') || opts.delete('--help') config_file = File.expand_path(args.first) is_dry = (opts.delete('-n') || opts.delete('--dry-run')) && !opts.delete('--not-dry-run') is_verbose = (opts.delete('-v') || opts.delete('--verbose')) && !opts.delete('--not-verbose') is_local_only = (opts.delete('-L') || opts.delete('--local')) && !opts.delete('--not-local') unless File.exist?(config_file) die 'Missing configuration file. NOT CREATED! Rerun w/o the -n argument to create a template configuration file.' if is_dry FileUtils.cp File.join(WebTranslateIt::Safe::ROOT, 'templates', 'script.rb'), config_file die "Created default #{config_file}. Please edit and run again." end config = eval(File.read(config_file)) config[:verbose] = is_verbose config[:dry_run] = is_dry config[:local_only] = is_local_only process config end main
Version data entries
5 entries across 5 versions & 1 rubygems