Sha256: 7e101e562d941377e1d04df9950b4ac638a12d22e8f04e9c4b7d3feb3055ffcf

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'deadpull'
require 'optparse'

options = OpenStruct.new
options.upload = false
options.verbose = false

opt_parser = OptionParser.new do |opts|
  opts.banner = 'Usage: deadpull [options] <path>'

  opts.separator ''
  opts.separator 'Options:'

  opts.on('-u', '--upload', 'Push to S3 from given path') do |v|
    options.upload = v
  end

  opts.on('-e', '--environment [ENVIRONMENT]', 'Provides environment, superseding DEADPULL_ENV and RAILS_ENV') do |v|
    options.environment = v
  end

  opts.on('-p', '--path [PATH]',
          'S3 path to be used for upload or download in form of bucket-name/prefix. Supersedes config.') do |v|
    options.path = v
  end

  opts.on('-a', '--aws [AWS]', 'AWS configuration hash in the form of a JSON string. Supersedes config.') do |v|
    options.aws = JSON.parse(v).symbolize_keys
  end

  opts.on('-v', '--[no-]verbose', 'Explicitly print used configuration.') do |v|
    options.verbose = v
  end

  opts.separator ''
  opts.separator 'Common options:'

  opts.on_tail('-h', '--help', 'Show this message') do
    puts opts
    exit
  end
end

opt_parser.parse!(ARGV)

local_path = ARGV.last

environment = Deadpull::Values::Environment.concretize(options.environment)
configuration = Deadpull::Values::Configuration.concretize
configuration[:path] = options.path if options.path
configuration[:aws] = options.aws if options.aws

pp(configuration) if options.verbose

if options.upload
  Deadpull::Commands::Push.call(local_path, configuration, environment)
else
  Deadpull::Commands::Pull.call(local_path, configuration, environment)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deadpull-0.1.1 exe/deadpull
deadpull-0.1.0 exe/deadpull