package ocamline

  1. Overview
  2. Docs
Command line interface for user input

Install

Dune Dependency

Authors

Maintainers

Sources

1.2.tar.gz
md5=b10a0fbce3bbaf2cac52e99a148d4ea4
sha512=3971622d10fe8c25e521272884fb46ac5a9ed1b54dbcbca1b84cbdab49eec869f0083df22ab2f46625faa052900c313e6ce2ac7317c0b8661d699fb749390540

Description

Published: 30 Jan 2020

README

ocamline

This library provides a simple interface for reading user input in OCaml programs. The goal of this project is to reduce the burden of reading user input for programming language REPLs.

The feature that makes this library particularly useful is its handling of brackets. Any brackets that are opened must be closed before input is accepted. This library uses ocaml-linenoise to provide rlwrap like functionality, including command history, arrow navigation, etc.

Example

Source Code:
read ~brackets:['(',')'] ~prompt:"lisp>" ()
Command Line:
lisp> (lambda
          (x)
          (+ x 1))
lisp>

API

val read :  ?trim_delim:bool ->
            ?brackets:(char * char) list ->
            ?prompt:string ->
            ?strings:char list ->
            ?history_loc:string ->
            ?hints_callback:(string -> (string * LNoise.hint_color * bool) option) ->
            ?completion_callback:(string -> LNoise.completions -> unit) ->
            ?delim:string ->
            unit ->
            string
Parameter Description Default Value
trim_delim Whether or not to remove the line delimiter from the return value. false
brackets Any characters that once opened must be closed before the line is accepted []
prompt Customizes the prompt displayed to the user. ">"
strings String delimiters. If brackets are in strings, they won't have to be closed. []
history_loc Where to store the history for the user commands ".ocamline_history.txt"
hints_callback Linenoise's hints callback. See here No op
completion_callback Linenoise's completion callback. See here No op
delim The string that, when found, halts scanning and returns the input. "" (* newlines *)

Contributions

Contributions to ocamline are greatly appreciated! ❤️

Please try to keep its implementation unassuming and configurable. 🙂

Dependencies (3)

  1. linenoise
  2. dune >= "1.9"
  3. ocaml

Dev Dependencies (1)

  1. alcotest with-test

Used by (1)

  1. gobba >= "0.4.2"

Conflicts

None