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

com.ebiznext.comet.job.atlas.AtlasConfig.scala Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package com.ebiznext.comet.job.atlas

import com.ebiznext.comet.utils.CliConfig
import scopt.OParser

case class AtlasConfig(
  delete: Boolean = false,
  folder: Option[String] = None,
  uris: Option[List[String]] = None,
  user: Option[String] = None,
  password: Option[String] = None,
  files: List[String] = Nil
)

object AtlasConfig extends CliConfig[AtlasConfig] {

  val parser: OParser[Unit, AtlasConfig] = {
    val builder = OParser.builder[AtlasConfig]
    import builder._
    OParser.sequence(
      programName("comet atlas"),
      head("comet", "atlas", "[options]"),
      note(""),
      opt[Unit]("delete")
        .action((_, c) => c.copy(delete = true))
        .optional()
        .text("Should we delete the previous schemas ?"),
      opt[String]("folder")
        .action((x, c) => c.copy(folder = Some(x)))
        .optional()
        .text("Folder with yaml schema files"),
      opt[String]("uris")
        .action((x, c) => c.copy(uris = Some(x.split(",").toList.map(_.trim))))
        .optional()
        .text("Atlas URI"),
      opt[String]("user")
        .action((x, c) => c.copy(user = Some(x)))
        .optional()
        .text("Atlas User"),
      opt[String]("password")
        .action((x, c) => c.copy(password = Some(x)))
        .optional()
        .text("Atlas password"),
      opt[String]("files")
        .action((x, c) => c.copy(files = x.split(",").toList.map(_.trim)))
        .optional()
        .text("List of YML files")
    )
  }
  // comet atlas  --delete --files file1,file2 --folder uri
  def parse(args: Seq[String]): Option[AtlasConfig] = OParser.parse(parser, args, AtlasConfig())
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy