ajalt/clikt

Kotlinajalt.github.io/clikt/

Multiplatform command line interface parsing for Kotlin

kotlinkotlin-librarycommand-linecommand-line-parseroption-parserargument-parserargument-parsingcli
スター成長
スター
3k
フォーク
135
週間成長
+3
Issue
33
1k2k3k
2018年4月2021年1月2023年11月2026年9月
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 macOS

What does it look like? Here's a complete example of a simple Clikt program:

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<String>) = 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.

There are also a number of sample applications. You can run them with the included runsample script.

Installation

Clikt is distributed through Maven Central.

dependencies {
   implementation("com.github.ajalt.clikt:clikt:5.1.0")

   // optional support for rendering markdown in help messages
   implementation("com.github.ajalt.clikt:clikt-markdown:5.1.0")
}

There is also a smaller core module available. See the docs for details.

If you're using Maven instead of Gradle, use <artifactId>clikt-jvm</artifactId>

Multiplatform

Clikt supports most multiplatform targets. See the docs for more information about functionality supported on each target. You'll need to use Gradle 6 or newer.

Snapshots

Snapshot builds are also available

Sonatype has instructions for consuming snapshots

You'll need to add the Central Portal snapshots repository:

repositories {
    maven {
        url = uri("https://central.sonatype.com/repository/maven-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 at

    http://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.
関連リポジトリ
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

awesomeGNU General Public License v3.0pythonjavascript
weibo.com/justjavac
118.8k28.3k
JetBrains/kotlin

The Kotlin Programming Language.

Kotlinkotlinprogramming-language
kotlinlang.org
53.4k6.4k
lysine-dev/okhttp

A meticulous HTTP client for the JVM, Android, and GraalVM.

KotlinlibraryApache License 2.0javaandroid
lysine.dev/okhttp/
47.1k9.3k
gkd-kit/gkd

基于无障碍,高级选择器,订阅规则的自定义屏幕点击安卓应用 | An Android APP with custom screen tapping based on Accessibility, Advanced Selectors, and Subscription Rules

KotlinappGNU General Public License v3.0androidkotlin
gkd.li
41.6k2k
yuliskov/SmartTube

Browse media content with your own rules on Android TV

JavaMavenappMIT Licenseandroidandroid-tv
smarttubeapp.github.io
32.7k2k
square/leakcanary

A memory leak detection library for Android.

KotlinlibraryApache License 2.0androidmemory-leak
square.github.io/leakcanary
30k4k
JunkFood02/Seal

🦭 Video/Audio Downloader for Android, based on yt-dlp

KotlinappGNU General Public License v3.0androidjetpack-compose
28.8k1.4k
NativeScript/NativeScript

⚡ Write Native with TypeScript ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Flutter and you name it compatible.

TypeScriptnpmMIT Licensenativescriptandroid
nativescript.org
25.6k1.7k
mihonapp/mihon

Free and open source manga reader for Android

KotlinappApache License 2.0androidkotlin
23.5k1.5k
android/nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose

KotlinappApache License 2.0androidjetpack-compose
21.8k4.6k
google/iosched

The Google I/O Android App

KotlinappApache License 2.0kotlinarchitecture
21.6k6.1k
open-ani/animeko

集找番、追番、看番的一站式弹幕追番平台,云收藏同步 (Bangumi),离线缓存,BitTorrent,弹幕云过滤。100% Kotlin/Compose Multiplatform

KotlinGNU Affero General Public License v3.0animecompose
animeko.org
20k563