package inquire
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d738b9b264934004e6b3926a7ba9e7c637429e86893316e93a12f3812a1ba782
sha512=d081e9b8d886d1b321e6d2fe69a83f8c432c6c5150496e2389e9c3ecc2cebfb39248980b3286c622574250e36f0553189f16d908cb52043acc7f841201e8b45b
doc/inquire.lib/Inquire/index.html
Module Inquire
Source
Inquire is a high-level library to create interactive command line interfaces.
Create a new implementation of Inquire to customize the prompts.
module Minimal : sig ... end
Minimal implementation of Inquire with no color and no prompt prefixes.
module Default : sig ... end
Default implementation of Inquire with hopefully nice colors and prefixes.
val confirm : ?default:Base.bool -> Base.String.t -> Base.bool Lwt.t
Prompt the user to answer the given message with "y" or "n".
Examples
let result =
Inquire.confirm "Are you sure?" ~default:true >>= fun choice ->
if choice then Lwt_io.printl "Yes!" else Lwt_io.printl "No!"
in
Lwt_main.run result
val raw_list :
?default:Base.bool ->
options:Base.string Base.list ->
Base.String.t ->
Base.String.t Lwt.t
Prompt the user to chose a value from the given options.
The options will be listed with an index prefixed and the users will have to enter the index of their choice.
Examples
let movies =
[ "Star Wars: The Rise of Skywalker"
; "Solo: A Star Wars Story"
; "Star Wars: The Last Jedi"
; "Rogue One: A Star Wars Story"
; "Star Wars: The Force Awakens"
]
in
let result =
Inquire.raw_list "What's your favorite movie?" ~options:movies
>>= fun movie -> Lwt_io.printlf "Indeed, %S is a great movie!" movie
in
Lwt_main.run result
val password : Base.String.t -> Base.String.t Lwt.t
Prompt the user to enter a password that will be hidden with stars ('*').
The password can take any value, except the empty string.
Examples
let result =
Inquire.password "Enter your password:" >>= fun password ->
Lwt_io.printlf "Your new password is: %S" password
in
Lwt_main.run result
val input : Base.String.t -> Base.String.t Lwt.t
Prompt the user to input a string.
The string can take any value, except the empty string.
Examples
let result =
Inquire.input "Enter a value:" >>= fun value ->
Lwt_io.printlf "You entered: %S" value
in
Lwt_main.run result