All Projects → ajalt → Clikt

ajalt / Clikt

Licence: apache-2.0
Multiplatform command line interface parsing for Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Clikt

Clipp
easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation
Stars: ✭ 687 (-58.56%)
Mutual labels:  cli, command-line, argument-parser, argument-parsing, option-parser
Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (+97.77%)
Mutual labels:  cli, command-line, command-line-parser, argument-parser, argument-parsing
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+98.19%)
Mutual labels:  cli, command-line, command-line-parser, argument-parsing
declarative-parser
Modern, declarative argument parser for Python 3.6+
Stars: ✭ 31 (-98.13%)
Mutual labels:  argument-parser, argument-parsing, option-parser, command-line-parser
Lyra
A simple to use, composable, command line parser for C++ 11 and beyond
Stars: ✭ 238 (-85.65%)
Mutual labels:  cli, argument-parser, argument-parsing, option-parser
Argumentparser
Faster, easier, more declarative parsing of command line arguments in Objective-C/Foundation.
Stars: ✭ 251 (-84.86%)
Mutual labels:  command-line, command-line-parser, argument-parser, argument-parsing
Clap
Create your command-line parser, with all of the bells and whistles, declaratively or procedurally.
Stars: ✭ 7,174 (+332.69%)
Mutual labels:  command-line, command-line-parser, argument-parser, argument-parsing
Argh
Argh! A minimalist argument handler.
Stars: ✭ 752 (-54.64%)
Mutual labels:  cli, command-line, command-line-parser, argument-parser
Commander
🚀The framework to write type-safe and structured command line program easily in Swift.
Stars: ✭ 170 (-89.75%)
Mutual labels:  cli, command-line, command-line-parser
argparser
Simple command-line parser for C/C++ programs
Stars: ✭ 50 (-96.98%)
Mutual labels:  argument-parser, option-parser, command-line-parser
CmdLine2
Command line argument parser (C++14)
Stars: ✭ 18 (-98.91%)
Mutual labels:  argument-parser, option-parser, command-line-parser
Deno Cliffy
Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Stars: ✭ 149 (-91.01%)
Mutual labels:  cli, command-line, argument-parser
option-parser
A Lightweight, header-only CLI option parser for C++
Stars: ✭ 16 (-99.03%)
Mutual labels:  argument-parser, option-parser, command-line-parser
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-92.4%)
Mutual labels:  cli, command-line, command-line-parser
Yaap
Yet Another (Swift) Argument Parser
Stars: ✭ 124 (-92.52%)
Mutual labels:  cli, argument-parser, argument-parsing
dropt
dropt is yet another C library for parsing command-line options.
Stars: ✭ 39 (-97.65%)
Mutual labels:  argument-parser, option-parser, command-line-parser
Argparse
Argparse for golang. Just because `flag` sucks
Stars: ✭ 294 (-82.27%)
Mutual labels:  cli, command-line-parser, argument-parser
Spectre.cli
An extremely opinionated command-line parser.
Stars: ✭ 121 (-92.7%)
Mutual labels:  cli, command-line, command-line-parser
Getopt Php
A PHP library for command-line argument processing
Stars: ✭ 305 (-81.6%)
Mutual labels:  cli, command-line, argument-parser
Kotlin Argparser
Easy to use and concise yet powerful and robust command line argument parsing for Kotlin
Stars: ✭ 431 (-74%)
Mutual labels:  command-line-parser, argument-parser, option-parser

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, NodeJS, 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(help="Number of greetings").int().default(1)
    val name: String by option(help="The person to greet").prompt("Your name")

    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:

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

dependencies {
   implementation("com.github.ajalt.clikt:clikt:3.3.0")
}
In version 3.0, the maven coordinates changed. Make sure you're using the new coordinates if you're updating from an older version.
If you're using Maven instead of Gradle, use <artifactId>clikt-jvm</artifactId>

Multiplatform

Clikt supports the following targets: jvm, mingwX64, linuxX64, macosX64, and js (for both NodeJS 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-2021 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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].