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

com.ebiznext.comet.job.metrics.MetricsConfig.scala Maven / Gradle / Ivy

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

import com.ebiznext.comet.schema.model.Stage
import com.ebiznext.comet.utils.CliConfig
import scopt.OParser

case class MetricsConfig(domain: String = "", schema: String = "", stage: Option[Stage] = None)

object MetricsConfig extends CliConfig[MetricsConfig] {

  val parser: OParser[Unit, MetricsConfig] = {
    val builder = OParser.builder[MetricsConfig]
    import builder._
    OParser.sequence(
      programName("comet metrics"),
      head("comet", "metrics", "[options]"),
      note(""),
      opt[String]("domain")
        .action((x, c) => c.copy(domain = x))
        .required()
        .text("Domain Name"),
      opt[String]("schema")
        .action((x, c) => c.copy(schema = x))
        .required()
        .text("Schema Name"),
      opt[String]("stage")
        .action((x, c) => c.copy(stage = Some(Stage.fromString(x))))
        .optional()
        .text("Stage (UNIT or GLOBAL)")
    )
  }

  /** Function to parse command line arguments (domain and schema).
    *
    * @param args : Command line parameters
    * @return : an Option of MetricConfing with the parsed domain and schema names.
    */
  def parse(args: Seq[String]): Option[MetricsConfig] = {
    OParser.parse(parser, args, MetricsConfig())
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy