this repo has no description
1opam-version: "2.0"
2maintainer: "Edgar Aroutiounian <edgar.factorial@gmail.com>"
3authors: "Edgar Aroutiounian <edgar.factorial@gmail.com>"
4homepage: "https://github.com/fxfactorial/ocaml-linenoise"
5bug-reports: "https://github.com/fxfactorial/ocaml-linenoise/issues"
6license: "BSD-3-Clause"
7dev-repo: "git+https://github.com/fxfactorial/ocaml-linenoise.git"
8build: [
9 ["oasis" "setup"]
10 ["ocaml" "setup.ml" "-configure" "--prefix" prefix]
11 ["ocaml" "setup.ml" "-build"]
12 ["oasis" "setup"] {with-test}
13 ["ocaml" "setup.ml" "-configure" "--enable-tests"] {with-test}
14 ["ocaml" "setup.ml" "-build"] {with-test}
15 ["ocaml" "setup.ml" "-test"] {with-test}
16]
17install: ["ocaml" "setup.ml" "-install"]
18remove: ["ocamlfind" "remove" "linenoise"]
19depends: [
20 "ocaml" {>= "4.03.0"}
21 "oasis" {build & >= "0.4"}
22 "ocamlfind" {build}
23]
24synopsis: "Simple readline like functionality with nice hints feature."
25description: """
26These are self contained OCaml bindings to linenoise,
27no system libraries needed at all.
28
29Here's a simple program:
30
31let rec user_input prompt cb =
32 match LNoise.linenoise prompt with
33 | None -> ()
34 | Some v ->
35 cb v;
36 user_input prompt cb
37
38let () =
39 LNoise.set_hints_callback (fun line ->
40 if line <> "git remote add " then None
41 else Some (" <this is the remote name> <this is the remote URL>",
42 LNoise.Yellow,
43 true)
44 );
45 LNoise.history_load ~filename:"history.txt" |> ignore;
46 LNoise.history_set ~max_length:100 |> ignore;
47 LNoise.set_completion_callback begin fun line_so_far ln_completions ->
48 if line_so_far <> "" && line_so_far.[0] = 'h' then
49 ["Hey"; "Howard"; "Hughes";"Hocus"]
50 |> List.iter (LNoise.add_completion ln_completions);
51 end;
52 ["These are OCaml bindings to linenoise";
53 "get tab completion with <TAB>, type h then hit <TAB>";
54 "type quit to exit gracefully";
55 "By Edgar Aroutiounian\\n"]
56 |> List.iter print_endline;
57 (fun from_user ->
58 if from_user = "quit" then exit 0;
59 LNoise.history_add from_user |> ignore;
60 LNoise.history_save ~filename:"history.txt" |> ignore;
61 Printf.sprintf "Got: %s" from_user |> print_endline
62 )
63 |> user_input "test_program> "
64
65and compile with:
66$ ocamlfind ocamlopt ex.ml -package linenoise -linkpkg -o T"""
67flags: light-uninstall
68url {
69 src: "https://github.com/fxfactorial/ocaml-linenoise/archive/v1.0.0.tar.gz"
70 checksum: [
71 "sha256=ef729a240c8278a1aad36b5d807eabb45c33d4d24a4a11a6d2e33fcc89f65386"
72 "md5=ea88336d4231b02c1ae4ed142c66be2c"
73 ]
74}