Sha256: a67a70a9ca6943c81979f59d6efd94213763de6ca93aef1bc750ebe3ed187c59

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

require 'ardb'

module Ardb; end
class Ardb::Runner
  UnknownCmdError = Class.new(ArgumentError)
  CmdError = Class.new(RuntimeError)
  CmdFail = Class.new(RuntimeError)

  attr_reader :cmd_name, :cmd_args, :opts

  def initialize(args, opts)
    @opts = opts
    @cmd_name = args.shift || ""
    @cmd_args = args
  end

  def run
    $LOAD_PATH.push(Dir.pwd) unless $LOAD_PATH.include?(Dir.pwd)
    Ardb.init(false) # don't establish a connection

    case @cmd_name
    when 'migrate'
      require 'ardb/runner/migrate_command'
      MigrateCommand.new.run
    when 'generate'
      require 'ardb/runner/generate_command'
      GenerateCommand.new(@cmd_args).run
    when 'create'
      require 'ardb/runner/create_command'
      CreateCommand.new.run
    when 'drop'
      require 'ardb/runner/drop_command'
      DropCommand.new.run
    when 'connect'
      require 'ardb/runner/connect_command'
      ConnectCommand.new.run
    when 'null'
      NullCommand.new.run
    else
      raise UnknownCmdError, "unknown command `#{@cmd_name}`"
    end
  end

  class NullCommand
    def run
      # if this was a real command it would do something here
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ardb-0.26.0 lib/ardb/runner.rb
ardb-0.25.0 lib/ardb/runner.rb
ardb-0.24.0 lib/ardb/runner.rb
ardb-0.23.0 lib/ardb/runner.rb
ardb-0.22.1 lib/ardb/runner.rb
ardb-0.22.0 lib/ardb/runner.rb
ardb-0.21.0 lib/ardb/runner.rb
ardb-0.20.0 lib/ardb/runner.rb
ardb-0.19.0 lib/ardb/runner.rb
ardb-0.18.0 lib/ardb/runner.rb