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

com.ebiznext.comet.job.ingest.LoadConfig.scala Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
/*
 *
 *  * Licensed to the Apache Software Foundation (ASF) under one or more
 *  * contributor license agreements.  See the NOTICE file distributed with
 *  * this work for additional information regarding copyright ownership.
 *  * The ASF licenses this file to You under the Apache License, Version 2.0
 *  * (the "License"); you may not use this file except in compliance with
 *  * the License.  You may obtain a copy of the License at
 *  *
 *  *    http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 *
 */

package com.ebiznext.comet.job.ingest

import com.ebiznext.comet.utils.CliConfig
import org.apache.hadoop.fs.Path
import scopt.OParser

/**
  * @param domain     domain name of the dataset
  * @param schema     schema name of the dataset
  * @param paths      Absolute path of the file to ingest (present in the ingesting area of the domain)
  */
case class LoadConfig(
  domain: String = "",
  schema: String = "",
  paths: List[Path] = Nil
)

object LoadConfig extends CliConfig[LoadConfig] {

  val parser: OParser[Unit, LoadConfig] = {
    val builder = OParser.builder[LoadConfig]
    import builder._
    OParser.sequence(
      programName("comet load | ingest"),
      head("comet", "load | ingest", "[options]"),
      note(""),
      arg[String]("domain")
        .required()
        .action((x, c) => c.copy(domain = x))
        .text("Domain name"),
      arg[String]("schema")
        .required()
        .action((x, c) => c.copy(schema = x))
        .text("Schema name"),
      arg[String]("paths")
        .required()
        .action((x, c) => c.copy(paths = x.split(',').map(new Path(_)).toList))
        .text("list of comma separated paths")
    )
  }

  def parse(args: Seq[String]): Option[LoadConfig] = {
    OParser.parse(parser, args, LoadConfig())
  }

  def main(args: Array[String]): Unit = {
    println(LoadConfig.usage())
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy