pusk/lib/utils.ml

34 lines
620 B
OCaml
Raw Normal View History

exception Any of string
2023-05-12 20:04:04 +02:00
let fmt = Printf.sprintf
2023-05-15 16:28:24 +02:00
type context =
{ session_id : string
; debug : bool
2024-01-26 15:44:28 +01:00
; hashtag : bool
2023-05-15 16:28:24 +02:00
}
2023-05-13 19:58:48 +02:00
let load_dotenv =
(* Load variables *)
let path = "config/.env" in
if Sys.file_exists path then Dotenv.export ~path ()
;;
2023-05-13 22:13:26 +02:00
2024-01-26 15:44:28 +01:00
let boolean_env variable =
match Sys.getenv_opt variable with
| Some boolean -> String.lowercase_ascii boolean = "true"
| None -> false
;;
2023-05-13 22:13:26 +02:00
let keys_to_typing str =
let rec aux acc = function
| 0 -> acc
| n -> aux (String.sub str (n - 1) 1 :: acc) (n - 1)
in
aux [] (String.length str)
;;
2023-05-14 01:44:11 +02:00
module Keys = struct
let return = "\\ue006"
end