diff --git a/bin/dune b/bin/dune index 6e1c201..81119cf 100644 --- a/bin/dune +++ b/bin/dune @@ -1,4 +1,6 @@ (executable (public_name github_tui) (name main) - (libraries github_tui)) + (libraries + github_tui + )) diff --git a/bin/main.ml b/bin/main.ml index 697271a..d76c3b3 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1,3 +1,4 @@ +(* let () = print_endline @@ Github_tui.Gh.query {| query { @@ -14,3 +15,6 @@ query { } } |} +*) + +let () = Github_tui.Tui.start () \ No newline at end of file diff --git a/dune-project b/dune-project index 8f0c659..87be024 100644 --- a/dune-project +++ b/dune-project @@ -7,12 +7,10 @@ (source (github chshersh/github-tui)) -(authors "Dmitrii Kovanikov") -(maintainers "Dmitrii Kovanikov") +(authors "Dmitrii Kovanikov ") +(maintainers "Dmitrii Kovanikov ") -(license LICENSE) - -(documentation https://url/to/documentation) +(license MPL-2.0) (package (name github_tui) @@ -22,8 +20,10 @@ ocaml dune ezcurl + minttea + terminal ) (tags - (topics "to describe" your project))) + (tui cli git github))) ; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project diff --git a/github_tui.opam b/github_tui.opam index e5a1e4a..0d22be2 100644 --- a/github_tui.opam +++ b/github_tui.opam @@ -2,17 +2,18 @@ opam-version: "2.0" synopsis: "A short synopsis" description: "A longer description" -maintainer: ["Dmitrii Kovanikov"] -authors: ["Dmitrii Kovanikov"] -license: "LICENSE" -tags: ["topics" "to describe" "your" "project"] +maintainer: ["Dmitrii Kovanikov "] +authors: ["Dmitrii Kovanikov "] +license: "MPL-2.0" +tags: ["tui" "cli" "git" "github"] homepage: "https://github.com/chshersh/github-tui" -doc: "https://url/to/documentation" bug-reports: "https://github.com/chshersh/github-tui/issues" depends: [ "ocaml" "dune" {>= "3.12"} "ezcurl" + "minttea" + "terminal" "odoc" {with-doc} ] build: [ diff --git a/lib/dune b/lib/dune index ffbb4ad..e775534 100644 --- a/lib/dune +++ b/lib/dune @@ -1,6 +1,10 @@ +(include_subdirs unqualified) + (library (name github_tui) (libraries ezcurl + minttea + terminal ) ) diff --git a/lib/tui.ml b/lib/tui.ml new file mode 100644 index 0000000..a8edc0d --- /dev/null +++ b/lib/tui.ml @@ -0,0 +1,2 @@ +let app = Minttea.app ~init:Init.init ~update:Update.update ~view:View.view () +let start () = Minttea.start app ~initial_model:Model.initial_model \ No newline at end of file diff --git a/lib/tui/init.ml b/lib/tui/init.ml new file mode 100644 index 0000000..f77180a --- /dev/null +++ b/lib/tui/init.ml @@ -0,0 +1,3 @@ +open Minttea + +let init _model = Command.Enter_alt_screen \ No newline at end of file diff --git a/lib/tui/model.ml b/lib/tui/model.ml new file mode 100644 index 0000000..4e097cd --- /dev/null +++ b/lib/tui/model.ml @@ -0,0 +1,13 @@ +type tab = + | Code + | Issues + | PullRequests + +type t = + { tab: tab ; + } + +let initial_model: t = + { + tab = Code; + } \ No newline at end of file diff --git a/lib/tui/update.ml b/lib/tui/update.ml new file mode 100644 index 0000000..cd35056 --- /dev/null +++ b/lib/tui/update.ml @@ -0,0 +1,17 @@ +open Minttea + +let update event (model: Model.t) = + match event with + (* if we press `q` or the escape key, we exit *) + | Event.KeyDown (Key "q" | Escape) -> (model, Command.Quit) + + (* if we press a digit, we switch to the corresponding tab *) + | Event.KeyDown (Key "1") -> + ({ tab = Model.Code }, Command.Noop) + | Event.KeyDown (Key "2") -> + ({ tab = Model.Issues }, Command.Noop) + | Event.KeyDown (Key "3") -> + ({ tab = Model.PullRequests }, Command.Noop) + + (* otherwise, we do nothing *) + | _ -> (model, Command.Noop) \ No newline at end of file diff --git a/lib/tui/view.ml b/lib/tui/view.ml new file mode 100644 index 0000000..a1dbbab --- /dev/null +++ b/lib/tui/view.ml @@ -0,0 +1,17 @@ +let view (model: Model.t) = + match model.tab with + | Code -> Format.sprintf + {| +Code + +|} + | Issues -> Format.sprintf + {| +Issues + +|} + | PullRequests -> Format.sprintf + {| +Pull Requests + +|} \ No newline at end of file