Sha256: f0418d153299b93d9cb1c692912ae1ebc8c276fa47c215f961f68268502518e5

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'thor'

module CropDuster
  class CLI < Thor

    desc "migrate", "Migrate the database to the latest version"
    option :db, required: true
    def migrate
      CropDuster.configure do |config|
        config.db = options[:db]
      end

      ActiveRecord::Migration.verbose = true
      ActiveRecord::Migrator.migrate File.join(File.dirname(__FILE__), "..", "..", "db", "migrate")
    end

    desc "import", "Migrate the database to the latest version"
    option :db, required: true
    option :aws_secret, required: true
    option :aws_key, required: true
    option :aws_billing_bucket
    def import
      set_configs(options[:db], options[:aws_secret], options[:aws_key], options[:aws_billing_bucket])
      CropDuster::Importer.import
    end

    desc "import_billing", "Imports billing information from AWS"
    option :db, required: true
    option :aws_secret, required: true
    option :aws_key, required: true
    option :aws_billing_bucket, required: true
    def import_billing
      set_configs(options[:db], options[:aws_secret], options[:aws_key], options[:aws_billing_bucket])
      CropDuster::Importer.import_billing
    end

    private
    def set_configs(db_url, aws_secret, aws_key, aws_billing_bucket = nil)
      CropDuster.configure do |config|
        config.db                 = db_url
        config.aws_secret         = aws_secret
        config.aws_key            = aws_key
        config.aws_billing_bucket = aws_billing_bucket
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crop-duster-0.0.7 lib/crop_duster/cli.rb