All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chrisomeara.pillar.cli.CommandExecutor.scala Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package com.chrisomeara.pillar.cli

import java.util.Date

import com.chrisomeara.pillar.{Migrator, Registry, Reporter}

object CommandExecutor {
  implicit private val migratorConstructor: ((Registry, Reporter) => Migrator) = Migrator.apply

  def apply(): CommandExecutor = new CommandExecutor()
}

class CommandExecutor(implicit val migratorConstructor: ((Registry, Reporter) => Migrator)) {
  def execute(command: Command, reporter: Reporter) {
    val migrator = migratorConstructor(command.registry, reporter)

    command.action match {
      case Initialize => migrator.initialize(command.session, command.keyspace)
      case Migrate => migrator.migrate(command.session, command.timeStampOption.map(new Date(_)))
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy