github-tui/lib/tui/app.ml

21 lines
781 B
OCaml
Raw Normal View History

2024-03-24 16:21:30 +03:00
let init ~repo ~root_dir_path : Model.initial_data =
let tree = Fs.read_tree root_dir_path in
let files =
2024-03-24 14:42:12 +03:00
match tree with
2024-03-24 16:21:30 +03:00
| Fs.File (path, _) ->
2024-03-24 14:42:12 +03:00
Printf.printf "Given path '%s' is not a directory!" path;
exit 1
2024-03-24 16:21:30 +03:00
| Fs.Dir (_, files) -> files
2024-03-24 14:42:12 +03:00
in
let height = Option.value (Terminal_size.get_rows ()) ~default:120 in
let width = Option.value (Terminal_size.get_columns ()) ~default:140 in
{ repo; root_dir_path; files; width; height }
let app = Minttea.app ~init:Init.init ~update:Update.update ~view:View.view ()
2024-03-24 16:21:30 +03:00
let start repo root_dir_path =
let initial_data = init ~repo ~root_dir_path in
let initial_model = Model.initial_model initial_data in
2024-06-22 13:52:14 +03:00
let config = Minttea.make_config ~fps:1 () in
Minttea.start ~config app ~initial_model