mirror of
https://github.com/chshersh/github-tui.git
synced 2024-09-11 18:37:56 +03:00
Refactor initial_data into a separate type
This commit is contained in:
parent
d0647d54ef
commit
d8a889e117
@ -11,7 +11,7 @@ let path_arg =
|
|||||||
& opt string "."
|
& opt string "."
|
||||||
& info [ "d"; "directory" ] ~docv:"DIRECTORY_PATH" ~doc)
|
& info [ "d"; "directory" ] ~docv:"DIRECTORY_PATH" ~doc)
|
||||||
|
|
||||||
let gh_tui_t = Term.(const Tui.App.start $ repo_arg $ path_arg)
|
let gh_tui_term = Term.(const Tui.App.start $ repo_arg $ path_arg)
|
||||||
|
|
||||||
let cmd =
|
let cmd =
|
||||||
let doc = "TUI of a GitHub repository" in
|
let doc = "TUI of a GitHub repository" in
|
||||||
@ -22,4 +22,4 @@ let cmd =
|
|||||||
]
|
]
|
||||||
in
|
in
|
||||||
let info = Cmd.info "gh-tui" ~version:"0.1.0" ~doc ~man in
|
let info = Cmd.info "gh-tui" ~version:"0.1.0" ~doc ~man in
|
||||||
Cmd.v info gh_tui_t
|
Cmd.v info gh_tui_term
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
let app = Minttea.app ~init:Init.init ~update:Update.update ~view:View.view ()
|
let init ~repo ~path : Model.initial_data =
|
||||||
|
|
||||||
let start repo path =
|
|
||||||
let tree = Fs.read_tree path in
|
let tree = Fs.read_tree path in
|
||||||
match tree with
|
match tree with
|
||||||
| Fs.File path ->
|
| Fs.File path ->
|
||||||
Printf.printf "Given path '%s' is not a directory!" path;
|
Printf.printf "Given path '%s' is not a directory!" path;
|
||||||
exit 1
|
exit 1
|
||||||
| Fs.Dir (dirname, files) ->
|
| Fs.Dir (dirname, files) -> { repo; dirname; files }
|
||||||
let initial_model = Model.initial_model ~repo ~dirname ~files in
|
|
||||||
Minttea.start app ~initial_model
|
let app = Minttea.app ~init:Init.init ~update:Update.update ~view:View.view ()
|
||||||
|
|
||||||
|
let start repo path =
|
||||||
|
let initial_data = init ~repo ~path in
|
||||||
|
let initial_model = Model.initial_model initial_data in
|
||||||
|
Minttea.start app ~initial_model
|
||||||
|
@ -16,5 +16,11 @@ type t = {
|
|||||||
code_tab : code_tab;
|
code_tab : code_tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
let initial_model ~repo ~dirname ~files =
|
type initial_data = {
|
||||||
|
repo : string;
|
||||||
|
dirname : string;
|
||||||
|
files : Fs.tree array;
|
||||||
|
}
|
||||||
|
|
||||||
|
let initial_model { repo; dirname; files } =
|
||||||
{ repo; current_tab = Code; code_tab = { dirname; fs = Fs.zip_it files } }
|
{ repo; current_tab = Code; code_tab = { dirname; fs = Fs.zip_it files } }
|
||||||
|
Loading…
Reference in New Issue
Block a user