Skip to content
المشاريع

حول

Type-level & seamless command-line argument parsing for Scala

أدوات التطوير

كيف تُقاس هذه الأرقام

ما يمكنك فعله

  • options defined as fields of case classes, with many supported types and default values
  • help message generation, customizable via annotations
  • shell completions (bash, zsh, fish)
  • a cats-effect module

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
٠
خلال 15 يومًا
٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

case-app

Type-level & seamless command-line argument parsing for Scala

Build status Maven Central javadoc

case-app is a command-line argument parser for Scala. You define options as the fields of a case class, and case-app parses arguments into it and generates help messages.

Quick start

Add case-app to your project. The latest version is shown in the Maven Central badge above. See the setup page for Scala.js, Scala Native, and more details.

// Scala CLI
//> using dep com.github.alexarchambault::case-app:2.2.0
// sbt
libraryDependencies += "com.github.alexarchambault" %% "case-app" % "2.2.0"
// Mill
def mvnDeps = Seq(mvn"com.github.alexarchambault::case-app:2.2.0")

Define your options in a case class, and your application as an object extending CaseApp:

import caseapp._

@ProgName("my-app")
case class Options(
  @HelpMessage("Name of the person to greet")
  @Name("n")
    name: String = "world",
  @HelpMessage("Number of greetings")
    count: Int = 1
)

object MyApp extends CaseApp[Options] {
  def run(options: Options, args: RemainingArgs): Unit =
    for (_ <- 1 to options.count)
      println(s"Hello ${options.name}!")
}

Running my-app -n Alex --count 2 prints Hello Alex! twice, and my-app --help prints

Usage: my-app [options]

Help options:
  --usage            Print usage and exit
  -h, -help, --help  Print help message and exit

Other options:
  -n, --name string  Name of the person to greet
  --count int        Number of greetings

Features

  • options defined as fields of case classes, with many supported types and default values
  • sub-commands
  • help message generation, customizable via annotations
  • shell completions (bash, zsh, fish)
  • a cats-effect module
  • runs on the JVM, Scala.js, and Scala Native

case-app is published for Scala 2.12, 2.13, and 3 on the JVM, and for Scala 3 on Scala.js and Scala Native (the cats-effect module is only published for Scala 3).

Documentation

See the website for more details, in particular:

Used by

case-app is used by coursier, Scala CLI, Almond, …

License

case-app is released under the Apache 2.0 license.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…