Coder Social home page Coder Social logo

ajalt / clikt Goto Github PK

View Code? Open in Web Editor NEW
2.4K 16.0 120.0 20.9 MB

Multiplatform command line interface parsing for Kotlin

Home Page: https://ajalt.github.io/clikt/

License: Apache License 2.0

Kotlin 99.58% Shell 0.31% Batchfile 0.11%
kotlin kotlin-library command-line command-line-parser option-parser argument-parser argument-parsing cli

clikt's Introduction

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:4.4.0")
}
If you're using Maven instead of Gradle, use <artifactId>clikt-jvm</artifactId>

Multiplatform

Clikt supports the following targets: jvm, mingwX64, linuxX64, linuxArm64, macosX64, macosArm64, and js and wasmJs (for both Node.js and Browsers). 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

You'll need to add the Sonatype snapshots repository:

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 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.