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
|
2024-04-07 13:50:38 +03:00
|
|
|
let height = Option.value (Terminal_size.get_rows ()) ~default:120 in
|
2024-04-07 14:54:08 +03:00
|
|
|
let width = Option.value (Terminal_size.get_columns ()) ~default:140 in
|
2024-04-07 13:50:38 +03:00
|
|
|
{ repo; root_dir_path; files; width; height }
|
2024-03-24 14:30:54 +03:00
|
|
|
|
|
|
|
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
|
2024-03-24 14:30:54 +03:00
|
|
|
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
|