<commit_before>package com.github.rollulus

import scopt._

object AppCommand extends Enumeration {
  type AppCommand = Value
  val NONE, LIST, INFO, DELETE = Value
}
import AppCommand._

object Defaults {
  val BaseUrl = "http://localhost:8083/"
}

case class Config(cmd: AppCommand= NONE, url: String = Defaults.BaseUrl)

object Go {
  def apply(cfg: Config) = {
    val api = new KafkaConnectApi(cfg.url)
    val fmt = new HumanFormatter()
    api.delete("twitter-source")
   // println(fmt.connectorInfo(api.connectorInfo("twitter-source")))
//    val ns = api.activeConnectorNames()
//    println(ns.mkString("\n"))

  }
}

object HelloWorld {
  def main(args: Array[String]): Unit = {

    val parser = new OptionParser[Config]("kafconcli") {
      head("kafconcli", "1.0")
      cmd("ls") action { (_, c) => c.copy(cmd = LIST) } text "list active connectors names" children()
      cmd("info") action { (_, c) => c.copy(cmd = INFO) } text "show information for the specified connector(s)" children()
      cmd("rm") action { (_, c) => c.copy(cmd = DELETE) } text "removes the specified connector(s)" children()
    }

    parser.parse(args, Config()) match {
      case Some(config) =>
        // do stuff
        Go(config)

      case None =>
        // arguments are bad, error message will have been displayed
        println("fail")
    }
  }
}

<commit_msg>Unleash new api functions to CLI<commit_after>package com.github.rollulus

import scopt._

object AppCommand extends Enumeration {
  type AppCommand = Value
  val NONE, LIST, INFO, DELETE, CREATE, RUN  = Value
}
import AppCommand._

object Defaults {
  val BaseUrl = "http://localhost:8083/"
}

case class Config(cmd: AppCommand= NONE, url: String = Defaults.BaseUrl, connectorNames: Seq[String] = Seq())


object Go {
  def allStdIn = Iterator.
    continually(io.StdIn.readLine).
    takeWhile(x => {x != null})

  lazy val R = "([^#].*)=(.*)".r
  def propsToJson(s:Seq[String]) = "{" + s.map(_ match {
    case R(k,v) => s""""${k.trim}":"${v.trim}""""
    case _ => ""
  }).filterNot(_.isEmpty).mkString(", ") + "}"

  def apply(cfg: Config) = {
    val api = new KafkaConnectApi(cfg.url)
    val fmt = new PropertiesFormatter()

    lazy val configuration = propsToJson(allStdIn.toSeq)

    cfg.cmd match {
      case LIST => println(fmt.connectorNames(api.activeConnectorNames))
      case DELETE => cfg.connectorNames.foreach(api.delete)
      case CREATE => cfg.connectorNames.foreach(api.addConnector(_, configuration))
      case RUN => cfg.connectorNames.foreach(api.updateConnector(_, configuration))
      case INFO => println(cfg.connectorNames.map(api.connectorInfo).map(fmt.connectorInfo).mkString("\n"))
    }

  }
}

object HelloWorld {
  def main(args: Array[String]): Unit = {

    val parser = new OptionParser[Config]("kafconcli") {
      head("kafconcli", "1.0")
      cmd("ls") action { (_, c) => c.copy(cmd = LIST) } text "list active connectors names" children()
      cmd("info") action { (_, c) => c.copy(cmd = INFO) } text "retrieves information for the specified connector(s)" children()
      cmd("rm") action { (_, c) => c.copy(cmd = DELETE) } text "removes the specified connector(s)" children()
      cmd("create") action { (_, c) => c.copy(cmd = CREATE) } text "creates the specified connector with the .properties from stdin" children()
      cmd("run") action { (_, c) => c.copy(cmd = RUN) } text "creates or updates the specified connector with the .properties from stdin" children()
      arg[String]("<connector-name>...") unbounded() optional() action { (x, c) =>
        c.copy(connectorNames = c.connectorNames :+ x) } text("connector name(s)")
    }

    parser.parse(args, Config()) match {
      case Some(config) =>
        // do stuff
        Go(config)

      case None =>
        // arguments are bad, error message will have been displayed
        println("fail")
    }
  }
}


{'fraction_non_alphanumeric': 0.1519117269694637, 'fraction_numerical': 0.003079291762894534, 'mean_word_length': 3.34075723830735, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4813326', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1224, 'n_words': 328}