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
|
(executable
|
||||||
(public_name github_tui)
|
(public_name github_tui)
|
||||||
(name main)
|
(name main)
|
||||||
(libraries github_tui))
|
(libraries
|
||||||
|
github_tui
|
||||||
|
))
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
(*
|
||||||
let () = print_endline @@ Github_tui.Gh.query
|
let () = print_endline @@ Github_tui.Gh.query
|
||||||
{|
|
{|
|
||||||
query {
|
query {
|
||||||
@ -14,3 +15,6 @@ query {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|}
|
|}
|
||||||
|
*)
|
||||||
|
|
||||||
|
let () = Github_tui.Tui.start ()
|
12
dune-project
12
dune-project
@ -7,12 +7,10 @@
|
|||||||
(source
|
(source
|
||||||
(github chshersh/github-tui))
|
(github chshersh/github-tui))
|
||||||
|
|
||||||
(authors "Dmitrii Kovanikov")
|
(authors "Dmitrii Kovanikov <chshersh@gmail.com>")
|
||||||
(maintainers "Dmitrii Kovanikov")
|
(maintainers "Dmitrii Kovanikov <chshersh@gmail.com>")
|
||||||
|
|
||||||
(license LICENSE)
|
(license MPL-2.0)
|
||||||
|
|
||||||
(documentation https://url/to/documentation)
|
|
||||||
|
|
||||||
(package
|
(package
|
||||||
(name github_tui)
|
(name github_tui)
|
||||||
@ -22,8 +20,10 @@
|
|||||||
ocaml
|
ocaml
|
||||||
dune
|
dune
|
||||||
ezcurl
|
ezcurl
|
||||||
|
minttea
|
||||||
|
terminal
|
||||||
)
|
)
|
||||||
(tags
|
(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
|
; 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"
|
opam-version: "2.0"
|
||||||
synopsis: "A short synopsis"
|
synopsis: "A short synopsis"
|
||||||
description: "A longer description"
|
description: "A longer description"
|
||||||
maintainer: ["Dmitrii Kovanikov"]
|
maintainer: ["Dmitrii Kovanikov <chshersh@gmail.com>"]
|
||||||
authors: ["Dmitrii Kovanikov"]
|
authors: ["Dmitrii Kovanikov <chshersh@gmail.com>"]
|
||||||
license: "LICENSE"
|
license: "MPL-2.0"
|
||||||
tags: ["topics" "to describe" "your" "project"]
|
tags: ["tui" "cli" "git" "github"]
|
||||||
homepage: "https://github.com/chshersh/github-tui"
|
homepage: "https://github.com/chshersh/github-tui"
|
||||||
doc: "https://url/to/documentation"
|
|
||||||
bug-reports: "https://github.com/chshersh/github-tui/issues"
|
bug-reports: "https://github.com/chshersh/github-tui/issues"
|
||||||
depends: [
|
depends: [
|
||||||
"ocaml"
|
"ocaml"
|
||||||
"dune" {>= "3.12"}
|
"dune" {>= "3.12"}
|
||||||
"ezcurl"
|
"ezcurl"
|
||||||
|
"minttea"
|
||||||
|
"terminal"
|
||||||
"odoc" {with-doc}
|
"odoc" {with-doc}
|
||||||
]
|
]
|
||||||
build: [
|
build: [
|
||||||
|
4
lib/dune
4
lib/dune
@ -1,6 +1,10 @@
|
|||||||
|
(include_subdirs unqualified)
|
||||||
|
|
||||||
(library
|
(library
|
||||||
(name github_tui)
|
(name github_tui)
|
||||||
(libraries
|
(libraries
|
||||||
ezcurl
|
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