Sha256: abbef77a26fc3a88a1a4d64b808a0842a3ee1c9f41a73dcf2334209c43a0653f

Contents?: true

Size: 1.88 KB

Versions: 3

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby

require 'active_support/core_ext/hash'
require 'thor'
require_relative '../lib/schema_dev/config'
require_relative '../lib/schema_dev/runner'
require_relative '../lib/schema_dev/version'

def runner
    $config ||= SchemaDev::Config.load
    $runner ||= SchemaDev::Runner.new($config)
end

class CLI < Thor

  def self.matrix_options
    method_option :dry_run, aliases: "-n", type: :boolean, desc: "Show what the commands would be without running them"
    method_option :quick, type: :boolean, desc: "Only execute on the 'quick' choice: #{$config ? $config.quick.inspect : "[from schema_dev.yml]"}"
    method_option :ruby, type: :string, desc: "Only execute for the specified version of ruby"
    method_option :rails, type: :string, desc: "Only execute for the specified version of rails"
    method_option :db, type: :string, desc: "Only execute for the specified database"
  end

  desc "travis", "create .travis.yml based on schema_dev.yml values"
  def travis
    runner.travis
  end

  desc "gemfiles", "create gemfiles/* hierarchy based on schema_dev.yml values"
  def gemfiles
    runner.gemfiles
  end

  desc "matrix", "run a command over the matrix"
  matrix_options
  def matrix(*args)
    runner.run(args, **options.to_h.symbolize_keys)
  end

  desc "bundle", "shorthand for '#{$0} matrix bundle ...'"
  matrix_options
  def bundle(*args)
    runner.run('bundle', args, **options.to_h.symbolize_keys)
  end

  desc "rake", "shorthand for '#{$0} matrix bundle exec rake ...'"
  matrix_options
  def rake(*args)
    runner.run('bundle', 'exec', 'rake', args, **options.to_h.symbolize_keys)
  end

  desc "rspec", "shorthand for '#{$0} bundle exec rspec ...'"
  matrix_options
  def rspec(*args)
    runner.run('bundle', 'exec', 'rspec', args, **options.to_h.symbolize_keys)
  end

end

if ARGV[0] == "--version"
    puts "SchemaDev #{SchemaDev::VERSION}"
    exit
end

CLI.start(ARGV)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
schema_dev-1.2.5 bin/schema_dev
schema_dev-1.2.4 bin/schema_dev
schema_dev-1.2.3 bin/schema_dev