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