package inquirer_oc

  1. Overview
  2. Docs
A collection of common interactive command line user interfaces

Install

Dune Dependency

Authors

Maintainers

Sources

v1.0.15.tar.gz
md5=9919506f08c2efde61b1f9ac70b77638
sha512=b8335b71c9b0c28dac0b3e9d961f8593d756c96d5edc35c042acde66a4eb51179439a785c6af844bfd3108802b6ad287de5a4476126227347ceade46e795608f

README.md.html

inquirer_oc

What does "inquirer_oc" library do?

Allow interaction on the CLI For example, you can have the user select one from multiple lists.

Currently, three types of question formats are implemented.

  1. list

  2. input

  3. confirm

usage

list

open Inquirer_oc

let question_option : Question_list_type.question =
  {
    name = "flower";
    prompt_type = List;
    message = "What's your favorite flower?";
    choices =
      [
        { word = "Sunflower"; value = "sunflower" };
        { word = "Tulip"; value = "tulip" };
        { word = "Rose"; value = "rose" };
        { word = "Daisy"; value = "daisy" };
        { word = "Lily"; value = "lily" };
      ];
    page_size = Some 5;
  }

let result = Question_list.list_question question_option
let () = print_endline result

image

advanced

If you want a simple string list with word and value together, there is a function to convert.

open Inquirer_oc

(* string list *)
let flower_list = [ "sunflower"; "tulip"; "rose"; "daisy"; "lily" ]

let question_option : Question_list_type.question =
  {
    name = "flower";
    prompt_type = List;
    message = "What's your favorite flower?";
    (* convert choices string x -> {word: x; value: x} *)
    choices = Question_list.string_list_to_choice_list flower_list;
    page_size = Some 5;
  }

let result = Question_list.list_question question_option
let () = print_endline result

input

open Inquirer_oc

let question_option : Question_input_type.question_input_option =
  {
    name = "flower";
    prompt_type = Input;
    message = "What's your favorite flower?";
    default = Some "rose";
  }

let result = Question_input.question_input question_option
let () = print_endline result

image

confirm

open Inquirer_oc

let question_option : Question_confirm_type.question_confirm_option =
  {
    name = "confirm";
    message = "Are you sure?";
    prompt_type = Confirm;
    default = Some true;
  }

let result = Question_confirm.inquirer_confirm question_option
let () = print_string (string_of_bool result)

image

OCaml

Innovation. Community. Security.