mirror of
https://github.com/chshersh/github-tui.git
synced 2024-09-11 18:37:56 +03:00
Add first TUI prototype
This commit is contained in:
parent
5d55263bd7
commit
e9d760cf39
4
bin/dune
4
bin/dune
@ -1,4 +1,6 @@
|
||||
(executable
|
||||
(public_name github_tui)
|
||||
(name main)
|
||||
(libraries github_tui))
|
||||
(libraries
|
||||
github_tui
|
||||
))
|
||||
|
@ -1,3 +1,4 @@
|
||||
(*
|
||||
let () = print_endline @@ Github_tui.Gh.query
|
||||
{|
|
||||
query {
|
||||
@ -14,3 +15,6 @@ query {
|
||||
}
|
||||
}
|
||||
|}
|
||||
*)
|
||||
|
||||
let () = Github_tui.Tui.start ()
|
12
dune-project
12
dune-project
@ -7,12 +7,10 @@
|
||||
(source
|
||||
(github chshersh/github-tui))
|
||||
|
||||
(authors "Dmitrii Kovanikov")
|
||||
(maintainers "Dmitrii Kovanikov")
|
||||
(authors "Dmitrii Kovanikov <chshersh@gmail.com>")
|
||||
(maintainers "Dmitrii Kovanikov <chshersh@gmail.com>")
|
||||
|
||||
(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
|
||||
|
@ -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 <chshersh@gmail.com>"]
|
||||
authors: ["Dmitrii Kovanikov <chshersh@gmail.com>"]
|
||||
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: [
|
||||
|
4
lib/dune
4
lib/dune
@ -1,6 +1,10 @@
|
||||
(include_subdirs unqualified)
|
||||
|
||||
(library
|
||||
(name github_tui)
|
||||
(libraries
|
||||
ezcurl
|
||||
minttea
|
||||
terminal
|
||||
)
|
||||
)
|
||||
|
2
lib/tui.ml
Normal file
2
lib/tui.ml
Normal file
@ -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
|
3
lib/tui/init.ml
Normal file
3
lib/tui/init.ml
Normal file
@ -0,0 +1,3 @@
|
||||
open Minttea
|
||||
|
||||
let init _model = Command.Enter_alt_screen
|
13
lib/tui/model.ml
Normal file
13
lib/tui/model.ml
Normal file
@ -0,0 +1,13 @@
|
||||
type tab =
|
||||
| Code
|
||||
| Issues
|
||||
| PullRequests
|
||||
|
||||
type t =
|
||||
{ tab: tab ;
|
||||
}
|
||||
|
||||
let initial_model: t =
|
||||
{
|
||||
tab = Code;
|
||||
}
|
17
lib/tui/update.ml
Normal file
17
lib/tui/update.ml
Normal file
@ -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)
|
17
lib/tui/view.ml
Normal file
17
lib/tui/view.ml
Normal file
@ -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
|
||||
|
||||
|}
|
Loading…
Reference in New Issue
Block a user