package spin
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=2d612f7a55a2cd71177e96c6a5a5d3a7c258b19b4eef9cf994a24b1ec77c3764
sha512=1b46b047c6f3d3ed38ba38912680e2af802517f30d27ae42ceca4fa1b3954d28ba6922535a322230a57e466f009df499823b39a325f476a9bf938fa2e0cd8f4a
doc/spin.inquire/Inquire/index.html
Module InquireSource
Inquire is a high-level library to create interactive command line interfaces.
Prompt the user to answer the given message with "y" or "n".
Examples
Inquire.confirm "Are you sure?" ~default:true |> fun choice ->
if choice then print_endline "Yes!" else print_endline "No!"val password :
?validate:(string -> (string, string) result) ->
?default:string ->
?style:Style.t ->
string ->
stringPrompt the user to enter a password that will be hidden.
The password can take any value, except the empty string.
On Unix, this works by setting the echo mode of the terminal to off.
On Windows, we print "\x1b8m" before prompting the password and "\x1b[0m" after. {4 Examples} {[ Inquire.password "Enter your password:" |> fun password -> print_endline "Your new password is: %S" password ]}
val input :
?validate:(string -> (string, string) result) ->
?default:string ->
?style:Style.t ->
string ->
stringPrompt the user to input a string.
The string can take any value, except the empty string.
Examples
Inquire.input "Enter a value:" |> fun value ->
print_endline "You entered: %S" valuePrompt 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.
Note that raw_select does not support more than 9 options. If you need more options, please use select instead.
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
Inquire.raw_select "What's your favorite movie?" ~options:movies
|> fun movie -> print_endline "Indeed, %S is a great movie!" moviePrompt the user to chose a value from the given options. The prompt is interactive and users can select their choice with directional keys.
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
Inquire.select "What's your favorite movie?" ~options:movies
|> fun movie -> print_endline "Indeed, %S is a great movie!" movieConfigure the behavior on user interruptions during a prompt.
If exit_on_user_interrupt is true, the program will exit with status code 130. If it is false, an Interrupted_by_user exception is raised.
The default behavior is to exit on user interruptions.