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

caseapp.core.complete.Fish.scala Maven / Gradle / Ivy

The newest version!
package caseapp.core.complete

object Fish {

  val shellName: String =
    "fish"
  val id: String =
    s"$shellName-v1"

  def script(progName: String): String =
    s"""complete $progName -a '($progName complete $id (math 1 + (count (__fish_print_cmd_args))) (__fish_print_cmd_args))'
       |""".stripMargin

  private def escape(s: String): String =
    s.replace("\t", "  ").linesIterator.find(_ => true).getOrElse("")
  def print(items: Seq[CompletionItem]): String = {
    val newLine = System.lineSeparator()
    val b       = new StringBuilder
    for (item <- items; value <- item.values) {
      b.append(escape(value))
      for (desc <- item.description) {
        b.append("\t")
        b.append(escape(desc))
      }
      b.append(newLine)
    }
    b.result()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy