this repo has no description
1let rec user_input prompt cb =
2 match LNoise.linenoise prompt with
3 | None -> ()
4 | Some v ->
5 cb v;
6 user_input prompt cb
7
8let () =
9 (* LNoise.set_multiline true; *)
10 LNoise.set_hints_callback (fun line ->
11 if line <> "git remote add " then None
12 else Some (" <this is the remote name> <this is the remote URL>",
13 LNoise.Yellow,
14 true)
15 );
16 LNoise.history_load ~filename:"history.txt" |> ignore;
17 LNoise.history_set ~max_length:100 |> ignore;
18 LNoise.set_completion_callback begin fun line_so_far ln_completions ->
19 if line_so_far <> "" && line_so_far.[0] = 'h' then
20 ["Hey"; "Howard"; "Hughes";"Hocus"]
21 |> List.iter (LNoise.add_completion ln_completions);
22 end;
23 ["These are OCaml bindings to linenoise";
24 "get tab completion with <TAB>, type h then hit <TAB>";
25 "type quit to exit gracefully";
26 "By Edgar Aroutiounian\n"]
27 |> List.iter print_endline;
28 (fun from_user ->
29 if from_user = "quit" then exit 0;
30 LNoise.history_add from_user |> ignore;
31 LNoise.history_save ~filename:"history.txt" |> ignore;
32 Printf.sprintf "Got: %s" from_user |> print_endline
33 )
34 |> user_input "test_program> "