Skip to content
Intuitive command line interface parsing for Kotlin
Branch: master
Clone or download
Latest commit 81f8ca1 Mar 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
clikt Update kotlin to 1.3.21 Mar 23, 2019
docs Add ClickCommand.printHelpOnEmptyArgs Jan 21, 2019
gradle/wrapper Update dependencies Sep 21, 2018
samples
.gitignore
.travis.yml Add travis.yml (#4) May 8, 2018
CHANGELOG.md
LICENSE.txt Add license Apr 8, 2018
README.md Release version 1.7.0 Mar 23, 2019
build.gradle
deploy.gradle Add maven central deployment Jun 23, 2018
gradle.properties Release version 1.7.0 Mar 23, 2019
gradlew Make gradlew executable. Nov 21, 2017
gradlew.bat
mkdocs.yml Fix mkdocs warning Oct 8, 2018
runsample Stop using run task in the runsample script Mar 20, 2018
settings.gradle Rename copy sample. Apr 14, 2018

README.md

Clikt (pronounced "clicked") is a Kotlin library that makes writing command line interfaces simple and intuitive. It's the "Command Line Interface for Kotlin".

Inspired by Python's Click, it is designed to make the process of writing command line tools efortless 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
  • support for a wide variety of command line interface styles

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

class Hello : CliktCommand() {
    val count: Int by option(help="Number of greetings").int().default(1)
    val name: String by option(help="The person to greet").prompt("Your name")

    override fun run() {
        for (i in 1..count) {
            echo("Hello $name!")
        }
    }
}

fun main(args: Array<String>) = Hello().main(args)

And here's what it looks like when run:

 $ ./hello --count=3
 Your name: John
 Hello John!
 Hello John!
 Hello John!

The help page is generated for you:

$ ./hello --help
Usage: hello [OPTIONS]

Options:
  --count INT  Number of greetings
  --name TEXT  The person to greet
  -h, --help   Show this message and exit

Errors are also taken care of:

$ ./hello --whoops
Usage: hello [OPTIONS]

Error: no such option: "--whoops".

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, Jcenter and Jitpack.

dependencies {
   implementation 'com.github.ajalt:clikt:1.7.0'
}

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.
You can’t perform that action at this time.