Implement CLI using Cmdliner

This commit is contained in:
Dmitrii Kovanikov 2024-01-07 14:59:21 +00:00
parent 06f9cf2b45
commit 0449be97f1
6 changed files with 20 additions and 21 deletions

View File

@ -19,11 +19,9 @@
(depends
(ocaml (>= "5.1"))
dune
(core (>= "v0.16.2"))
(core_unix (>= "v0.16.0"))
(cmdliner (>= "1.2.0"))
(ezcurl (>= "0.2.4"))
(minttea (>= "0.0.2"))
(ppx_jane (>= "v0.16.0"))
)
(tags
(tui cli git github)))

View File

@ -11,11 +11,9 @@ bug-reports: "https://github.com/chshersh/github-tui/issues"
depends: [
"ocaml" {>= "5.1"}
"dune" {>= "3.12"}
"core" {>= "v0.16.2"}
"core_unix" {>= "v0.16.0"}
"cmdliner" {>= "1.2.0"}
"ezcurl" {>= "0.2.4"}
"minttea" {>= "0.0.2"}
"ppx_jane" {>= "v0.16.0"}
"odoc" {with-doc}
]
build: [

View File

@ -1,10 +1,16 @@
open Core
open Cmdliner
let repo_param =
let open Command.Param in
anon ("owner/repo" %: string)
let repo_arg =
let doc = "The GitHub repository to launch." in
Arg.(value & pos 0 string "NOT_SPECIFIED" & info [] ~docv:"OWNER/REPO" ~doc)
let command =
Command.basic
~summary:"Display GitHub TUI for the selected repository"
(Command.Param.map repo_param ~f:(fun _repo () -> Tui.start ()))
let gh_tui_t = Term.(const Tui.start $ repo_arg)
let cmd =
let doc = "TUI of a GitHub repository" in
let man = [
`S Manpage.s_bugs;
`P "Submit bug reports at: https://github.com/chshersh/github-tui/issues" ]
in
let info = Cmd.info "gh-tui" ~version:"0.1.0" ~doc ~man in
Cmd.v info gh_tui_t

View File

@ -3,12 +3,8 @@
(library
(name github_tui)
(libraries
core
core_unix.command_unix
cmdliner
ezcurl
minttea
)
(preprocess
(pps ppx_jane)
)
)

View File

@ -1 +1 @@
let main () = Command_unix.run ~version:"0.1.0" ~build_info:"RWO" Cli.command
let main () = exit (Cmdliner.Cmd.eval Cli.cmd)

View File

@ -1,2 +1,3 @@
let app = Minttea.app ~init:Init.init ~update:Update.update ~view:View.view ()
let start () = Minttea.start app ~initial_model:Model.initial_model
let start _repo_name = Minttea.start app ~initial_model:Model.initial_model