···1414 ms
1515;;
16161717+1818+1719module Log = struct
1820 let timestamp_tag =
1921 Logs.Tag.def "timestamp" ~doc:"Timestamp" (fun fmt tm ->
···9092 match String.lowercase_ascii raw with "darwin" | "osx" -> "macos" | s -> s
9193 ;;
92949393- let poll_os () =
9494- let raw =
9595- match Sys.os_type with
9696- | "Unix" ->
9797- (try
9898- let uname_in = Unix.open_process_args_in "uname" [| "uname"; "-s" |] in
9999- let str = uname_in |> In_channel.input_all in
100100- Unix.wait()|>ignore;
101101- Some (str |> String.lowercase_ascii |> String.trim)
102102- with
103103- | _ ->
104104- None)
105105- | s ->
106106- Some (s |> String.lowercase_ascii |> String.trim)
107107- in
108108- match raw with None | Some "" -> None | Some s -> Some (normalise_os s)
109109- ;;
9595+1109611197 (*tries to get the logging dir for macos and linux*)
11298 let get_log_dir () =
11399 try
114114- let os = poll_os () in
100100+ let os = Os.poll_os () in
115101 let state_home =
116102 try
117103 match os with
+23
jj_tui/lib/os.ml
···11+module Internal = struct
22+let normalise_os raw =
33+ match String.lowercase_ascii raw with "darwin" | "osx" -> "macos" | s -> s
44+;;
55+end
66+77+let poll_os () =
88+ let raw =
99+ match Sys.os_type with
1010+ | "Unix" ->
1111+ (try
1212+ let uname_in = Unix.open_process_args_in "uname" [| "uname"; "-s" |] in
1313+ let str = uname_in |> In_channel.input_all in
1414+ Unix.wait()|>ignore;
1515+ Some (str |> String.lowercase_ascii |> String.trim)
1616+ with
1717+ | _ ->
1818+ None)
1919+ | s ->
2020+ Some (s |> String.lowercase_ascii |> String.trim)
2121+ in
2222+ match raw with None | Some "" -> None | Some s -> Some (Internal.normalise_os s)
2323+;;
+24
jj_tui/lib/util.ml
···7373 [] (* If list is empty or has only one element, return empty list *)
7474;;
75757676+module StrMap_=Map.Make(String)
7777+module StrMap =struct
7878+ open Yojson.Safe
7979+ include StrMap_
8080+ type t= string StrMap_.t
8181+ let to_yojson map : Yojson.Safe.t =
8282+ `Assoc (bindings map |> List.map (fun (k, v) -> k, `String v))
8383+ ;;
8484+ let of_yojson (json:Yojson.Safe.t) =
8585+8686+ match json with
8787+ |`Assoc(items)->
8888+ items|>List.map (fun (k,v)->
8989+ (v|>[%of_yojson: string ])
9090+ |>Result.map(fun x-> k,x)
9191+ )
9292+ |>
9393+ Base.Result.all
9494+ |>Result.map of_list
9595+9696+ |_-> Error ("Not an object")
9797+9898+ ;;
9999+end