Kotlin-CLI - command line interface options parser for Kotlin

Overview

kotlin-cli

Kotlin-CLI - command line option parsing suite for Kotlin

Usage

import com.evalab.core.cli.Command
import com.evalab.core.cli.exception.OptionException

fun main(args: Array<String>) {
    val command = Command("command", "Command just for testing")

    command.addBooleanOption("debug", false, 'd', "Flag of debug mode")
    command.addBooleanOption("verbose", false, 'v', "Returns detailed information")
    command.addIntegerOption("size", false, 's', "Sets size")
    command.addDoubleOption("fraction", false, 'f', "Sets fraction")
    command.addStringOption("name", true, 'n', "Sets name")

    try {
        command.parse(args)
    } catch (e: OptionException) {
        println(e.message)
        println(command.getHelp())
        System.exit(2)
    }

    val debug = command.getBooleanValue("debug", false)
    val verbose = command.getBooleanValue("verbose", false)
    val size = command.getIntegerValue("size", 0)
    val fraction = command.getDoubleValue("fraction", 0.0)
    val name = command.getStringValue("name")

    println("debug: " + debug)
    println("verbose: " + verbose)
    println("size: " + size)
    println("fraction: " + fraction)
    println("name: " + name)
}

Contact

Follow me @leprosus

License

MIT License. See the LICENSE file.

You might also like...
MemoryGame - An Android memory game with customizable options
MemoryGame - An Android memory game with customizable options

MemoryGame An Android memory game with customizable options Open source librarie

A Certificate Authority with RESTful interface and WEB UI
A Certificate Authority with RESTful interface and WEB UI

minica A Certificate Authority with RESTful interface and WEB UI Home page View CA detail View Cert Detail With RESTful interface, you can manage cert

Test tv - A marketing company needs a simple pluggable application with a RESTful interface

Demo project A marketing company needs a simple pluggable application with a RES

Discord bot interface for Spring Initializr
Discord bot interface for Spring Initializr

Spring Initializr interface over Discord. Initialize your new Spring Boot project right in the app.

Simplify the processing of sealed class/interface

shiirudo Generates DSL to simplify processing branching by when expressions in sealed class/interface. Setup Refer to the KSP quickstart guide to make

kotlin eval command for minestom

k Kotlin debugging evaulator in Minestom. Usage /k is shorthand, /ko is longhand requires the permission "k.ok" and "k.store" for running scripts and

🐹 Kotlin microservice to aid slash command creation for Nino.

slash-commands 🐹 .Kotlin microservice to aid slash command creation for Nino. More of this README will be fixed up once the first release is here. Li

🌨️ Simple, intuitive, and opinionated command handling library for Kord

🌨️ Snow Simple, intuitive, and opinionated command handling library for Kord Why? Since I maintain two Discord bots, both in Kotlin, Nino and Noel (p

Comments
  • Simple fix to example to make it compile.

    Simple fix to example to make it compile.

    This is my first pass at using this project. I used jitpack to consume the latest commit. I am running Kotlin 1.2. When copy/pasting the example code into my project, line 24 failed to compile. This change resolved the issue.

    opened by kgilmer 0
Owner
Denis Korolev
Denis Korolev
A command-line student management system in Kotlin

Student Management System Done as a part of NITK GSDC Android Study Jams 2021 Th

Ranjana Kambhammettu 2 Dec 24, 2021
A starter project to build command-line tools in Kotlin Multiplatform

A starter project to build command-line tools in Kotlin Multiplatform Contains a re-implementation of a real world CLI tool: git-standup Installation

null 0 May 2, 2022
Android application compatible with ZX2C4's Pass command line application

Password Store Download Documentation We're in the process of rewriting our documentation from scratch, and the work-in-progress state can be seen her

Android Password Store 2.2k Dec 29, 2022
Template for building CLI tool in Kotlin and producing native binary

Kotlin command-line native tool template This template allows you to quickly build command-line tool using Kotlin , Clikt and build a native binary fo

Ryszard Grodzicki 10 Dec 31, 2022
Kotlin cli maven spring failsafe findbugs cucumber mockito junit car data

Kotlin cli maven spring failsafe findbugs cucumber mockito junit car data

null 0 Feb 1, 2022
Kotlin CLI utilities, mostly intended for use with Clikt

Kotlin CLI Utils A repo containing basic CLI utilities for Kotlin. Installation dependencies { implementation("com.slack.cli:kotlin-cli-util:<versio

Slack 21 Jan 2, 2023
InstaKiller - InstaKiller is a CLI client for Instagram

InstaKiller InstaKiller is a CLI wrapper around instagram4j library. Icon Item ?

null 10 Apr 5, 2022
SSU u-saint parser with Kotlin-Multiplatform and Ktor.

kusaint Soongsil University(SSU) u-Saint Parser with Kotlin Multiplatform. Prerequisites JVM !!IMPORTANT!! To run kusaint as a library in JVM environm

Hyomin Koo 3 Mar 23, 2022
The app contains an order flow for cupcakes with options for quantity, flavor, and pickup date

Cupcake app This app contains an order flow for cupcakes with options for quantity, flavor, and pickup date. The order details get displayed on an ord

null 0 Nov 13, 2021
MI Pad 2 tablet advanced boot options

LatteGO MI Pad 2 tablet advanced boot options Features Hidden target device checker Simple GUI Reboot options Shutdown Recovery Fastboot DNX Reboot Sl

null 4 Oct 26, 2022