Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajalt/clikt
Multiplatform command line interface parsing for Kotlin
https://github.com/ajalt/clikt
argument-parser argument-parsing cli command-line command-line-parser kotlin kotlin-library option-parser
Last synced: 7 days ago
JSON representation
Multiplatform command line interface parsing for Kotlin
- Host: GitHub
- URL: https://github.com/ajalt/clikt
- Owner: ajalt
- License: apache-2.0
- Created: 2018-04-10T18:04:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-05T21:52:11.000Z (3 months ago)
- Last Synced: 2024-10-29T15:08:03.153Z (3 months ago)
- Topics: argument-parser, argument-parsing, cli, command-line, command-line-parser, kotlin, kotlin-library, option-parser
- Language: Kotlin
- Homepage: https://ajalt.github.io/clikt/
- Size: 21.7 MB
- Stars: 2,529
- Watchers: 18
- Forks: 120
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-kotlin - clikt - Multiplatform command line interface parsing for Kotlin (Libraries)
- awesome-kotlin-multiplatform - Clikt - Multiplatform command line interface parsing for Kotlin (Libraries / Command Line Interface)
- awesome-cli-frameworks - clikt
- awesome-list - ajalt/clikt - Multiplatform command line interface parsing for Kotlin (Kotlin)
- awesome-github-repos - ajalt/clikt - Multiplatform command line interface parsing for Kotlin (Kotlin)
- awesome-list - clikt
README
Clikt *(pronounced "clicked")* is a multiplatform Kotlin library that makes writing command line
interfaces simple and intuitive. It's the "Command Line Interface for Kotlin".It is designed to make the process of writing command line tools effortless
while supporting a wide variety of use cases and allowing advanced
customization when needed.Clikt has:
* arbitrary nesting of commands
* composable, type safe parameter values
* generation of help output and shell autocomplete scripts
* multiplatform packages for JVM, Node.js, and native Linux, Windows and macOSWhat does it look like? Here's a complete example of a simple Clikt program:
```kotlin
class Hello : CliktCommand() {
val count: Int by option().int().default(1).help("Number of greetings")
val name: String by option().prompt("Your name").help("The person to greet")override fun run() {
repeat(count) {
echo("Hello $name!")
}
}
}fun main(args: Array) = Hello().main(args)
```And here's what it looks like when run:
The help page is generated for you:
Errors are also taken care of:
## Documentation
The full documentation can be found on [the website](https://ajalt.github.io/clikt).
There are also a number of [sample applications](samples). You can run
them with the included [`runsample` script](runsample).## Installation
Clikt is distributed through [Maven Central](https://search.maven.org/artifact/com.github.ajalt.clikt/clikt).
```kotlin
dependencies {
implementation("com.github.ajalt.clikt:clikt:5.0.2")// optional support for rendering markdown in help messages
implementation("com.github.ajalt.clikt:clikt-markdown:5.0.2")
}
```There is also a smaller core module available. [See the docs for details](https://ajalt.github.io/clikt/advanced/#core-module).
###### If you're using Maven instead of Gradle, use `clikt-jvm`
#### Multiplatform
Clikt supports most multiplatform targets.
[See the docs](https://ajalt.github.io/clikt/advanced/#multiplatform-support)
for more information about functionality supported on each target. You'll need to use Gradle 6 or
newer.#### Snapshots
Snapshot builds are also available
You'll need to add the Sonatype snapshots repository:
```kotlin
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
```## License
Copyright 2018 AJ Alt
Licensed 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 athttp://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.