{0 Bruit} {! Bruit} is a pure OCaml port of {{: https://github.com/antirez/linenoise} linenoise}, which is itself a: {%html:
A minimal, zero-config, BSD licensed, readline replacement used in Redis, MongoDB, Android and many other projects.%} Other line editing tools exist such as {{: https://ocaml.org/p/ledit/latest} [ledit]}. {1:user_guides User guides} {ul {- Try the {{!quick_start} quick start} guide to get up and running quickly.} {- See the {{!manual} manual} for more complex examples.} } {1:library_bruit Library [bruit]} {!modules: Bruit } {1:library_unix Library [bruit.unix]} {!modules: Bruit_unix} {1:library_brr Library [bruit.brr]} {!modules: Bruit_brr} {1:quick_start Quick start} The following simple example first creates a portable line editing tool called [line_editor] and then passes a configuration to the {! Bruit_unix} backend for running the command line editor. It adds a simple completion to any string starting with ["hel"]. {[ let prompt = "> " let line_editor ctx = let complete s = if String.starts_with ~prefix:"hel" s then [ "hello"; "hello, world!" ] else [] in Bruit.run ~complete ctx prompt let () = let ctx = Bruit_unix.stdctx () in let rec loop () = match line_editor ctx with | String (Some s) -> Fmt.pr "%s\n%!" s; loop () | String None -> () | Ctrl_c -> Fmt.pr "\n%!"; loop () in loop () ]}