Coder Social home page Coder Social logo
kotlin-inquirer photo

kotlin-inquirer Goto Github PK

repos: 2.0 gists: 0.0

Name: kotlin-inquirer

Type: Organization

Bio: A common interactive command line user interfaces written in Kotlin

example workflow Apache License V.2 codecov Awesome Kotlin Badge

A collection of common interactive command line user interfaces written in Pure Kotlin inspired by Inquirer.js

🚀 Run Demo Using kscript

Remote scriplet raw-URL

kscript https://bit.ly/kotlin-inquirer-pizza

Or clone it

git clone https://github.com/kotlin-inquirer/kotlin-inquirer.git
cd kotlin-inquirer
kscript ./scripts/pizza.kts

Or without kscript

./gradlew shadowJar
java -jar example/build/libs/kotlin-pizza.jar

☁️ Download

Gradle

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.kotlin-inquirer:kotlin-inquirer:0.1.0'
}

📋 Usages

Confirm

val isDelivery: Boolean = KInquirer.promptConfirm(message = "Is this for delivery?", default = false)
println("Is Delivery: $isDelivery")


Input

val comments: String = KInquirer.promptInput(message = "Any comments on your purchase experience?")
println("Comments: $comments")


Input Numbers

val quantity: BigDecimal = KInquirer.promptInputNumber(message = "How many do you need?")
println("Quantity: $quantity")


Input Password

val password: String = KInquirer.promptInputPassword(message = "Enter Your Password:", hint = "password")
println("Password: $password")


Input Password custom mask

val passwordMasked: String = KInquirer.promptInputPassword(
    message = "Enter Your Password:",
    hint = "password",
    mask = "🤫"
)
println("Password: $passwordMasked")


List

val size: String = KInquirer.promptList(message = "What size do you need?", choices = listOf("Large", "Medium", "Small"))
println("Size: $size")


List with more options

val continent: String = KInquirer.promptList(
    message = "Select a continent:",
    choices = listOf(
        "Asia",
        "Africa",
        "Europe",
        "North America",
        "South America",
        "Australia",
        "Antarctica",
    ),
    hint = "press Enter to pick",
    pageSize = 3,
    viewOptions = ListViewOptions(
        questionMarkPrefix = "🌍",
        cursor = " 😎 ",
        nonCursor = "    ",
    )
)
println("Continent: $continent")


Checkbox

val toppings: List<String> = KInquirer.promptCheckbox(
    message = "What about the toppings?",
    choices = listOf(
        "Pepperoni and cheese",
        "All dressed",
        "Hawaiian",
    ),
)
println("Toppings: $toppings")


Checkbox with more options

val colors: List<String> = KInquirer.promptCheckbox(
    message = "Which colors do you prefer?",
    choices = listOf(
        "Red",
        "Green",
        "Blue",
        "Yellow",
        "Black",
        "White",
    ),
    hint = "pick a color using spacebar",
    maxNumOfSelection = 3,
    minNumOfSelection = 2,
    pageSize = 3,
    viewOptions = CheckboxViewOptions(
        questionMarkPrefix = "",
        cursor = " 👉 ",
        nonCursor = "    ",
        checked = "",
        unchecked = "",
    )
)
println("Colors: $colors")


🔮 Roadmap

Components

  • Confirm
  • Input
  • Input Numbers
  • Input Password
  • List
  • Checkbox
  • Input validation error message
  • Support Hint
  • Better package name
  • Add examples for ViewOption
  • Support List/Checkbox Fuzzy search
  • Support List/Checkbox autocomplete
  • Add DSL support
  • Consider non static function for prompts

Operation

  • Examples
  • Logo
  • GIFs
  • codecov
  • Maven Central

kotlin-inquirer's Projects

awesome-kotlin icon awesome-kotlin

A curated list of awesome Kotlin related stuff Inspired by awesome-java.

kotlin-inquirer icon kotlin-inquirer

A collection of common interactive command line user interfaces written in Kotlin

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.