# Scala-CLI-tools **Repository Path**: SuperWindcloud/scala-cli-tools ## Basic Information - **Project Name**: Scala-CLI-tools - **Description**: decline是一个可组合的命令行解析库 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-02 - **Last Updated**: 2024-12-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # decline 一个可组合的命令行解析器,灵感来自 ['optparse-applicative'][optparse] 并建立在 ['cats'][cats] 之上。 ```scala import cats.syntax.all._ import com.monovore.decline._ object HelloWorld extends CommandApp( name = "hello-world", header = "Says hello!", main = { val userOpt = Opts.option[String]("target", help = "Person to greet.") .withDefault("world") val quietOpt = Opts.flag("quiet", help = "Whether to be quiet.").orFalse (userOpt, quietOpt).mapN { (user, quiet) => if (quiet) println("...") else println(s"Hello $user!") } } ) ``` ## 快速开始 > `libraryDependencies += "com.monovore" %% "decline" % "2.4.2-SNAPSHOT"` - 编写示例 , 编译运行 ``` $ hello-world --help Usage: hello-world [--target ] [--quiet] Says hello! Options and flags: --help Display this help text. --target Person to greet. --quiet Whether to be quiet. $ hello-world --target friend Hello, friend!```