Sha256: 2ac4878f9caff96c6f2e54db50c4e1c966d6f82fa1818b08bd469e2901346d53

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

#!/usr/bin/ruby
require 'ferry'

OptionParser.new do |opts|
  options = {}
  opts.banner = "See more documentation at http://cmu-is-projects.github.io/ferry"

  opts.on("--import ENVIRONMENT TABLE FILEPATH", 'Imports data from specified file into table and environment of your specification') do |opt|
    raise "too many arguments for input" unless ARGV.length <= 2
    raise "please enter a field for environment and table and filename" unless ARGV.length == 2
    importer = Ferry::Importer.new
    importer.import(opt, ARGV[0], ARGV[1])
  end

  opts.on('-i', '--init', 'Initializes ferry.rb file in config directory') do |opt|
    filemaker = Ferry::Utilities.new
    filemaker.make_starter_file
  end

  opts.on("--to_csv ENVIRONMENT TABLE", 'Exports table to csv file in db/csv/[your db environment]/[your table]') do |opt|
    raise "too many arguments for input" unless ARGV.length <= 1
    raise "please enter a field for environment and table" unless ARGV.length == 1
    exporter = Ferry::Exporter.new
    exporter.to_csv(opt, ARGV[0])
  end

  opts.on("--to_json ENVIRONMENT TABLE", 'Exports table to json file in db/json/[your db environment]/[your table]') do |opt|
    raise "too many arguments for input" unless ARGV.length <= 1
    raise "please enter a field for environment and table" unless ARGV.length == 1
    exporter = Ferry::Exporter.new
    exporter.to_json(opt, ARGV[0])
  end

  opts.on("--to_yaml ENVIRONMENT TABLE", 'Exports table to yaml file in db/yaml/[your db environment]/[your table]') do |opt|
    raise "too many arguments for input" unless ARGV.length <= 1
    raise "please enter a field for environment and table" unless ARGV.length == 1
    exporter = Ferry::Exporter.new
    exporter.to_yaml(opt, ARGV[0])
  end

  opts.on( "-v", "--version", String, "Prints version of Ferry." ) do |opt|
    ferry_utils = Ferry::Utilities.new
    ferry_utils.print_version
  end

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

  puts opts if ARGV[0] == nil
end.parse!

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ferry-1.2.1 bin/ferry
ferry-1.2.0 bin/ferry