A collection of common interactive command line user interfaces written in 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
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.kotlin-inquirer:kotlin-inquirer:0.1.0'
}
val isDelivery: Boolean = KInquirer.promptConfirm(message = "Is this for delivery?", default = false)
println("Is Delivery: $isDelivery")
val comments: String = KInquirer.promptInput(message = "Any comments on your purchase experience?")
println("Comments: $comments")
val quantity: BigDecimal = KInquirer.promptInputNumber(message = "How many do you need?")
println("Quantity: $quantity")
val password: String = KInquirer.promptInputPassword(message = "Enter Your Password:", hint = "password")
println("Password: $password")
val passwordMasked: String = KInquirer.promptInputPassword(
message = "Enter Your Password:",
hint = "password",
mask = "🤫"
)
println("Password: $passwordMasked")
val size: String = KInquirer.promptList(message = "What size do you need?", choices = listOf("Large", "Medium", "Small"))
println("Size: $size")
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")
val toppings: List<String> = KInquirer.promptCheckbox(
message = "What about the toppings?",
choices = listOf(
"Pepperoni and cheese",
"All dressed",
"Hawaiian",
),
)
println("Toppings: $toppings")
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")
- 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
- Examples
- Logo
- GIFs
- codecov
- Maven Central