From 4472e8ae8a746aec0867d757e86d35fa75da38b6 Mon Sep 17 00:00:00 2001 From: Stavros Polymenis Date: Sat, 19 Nov 2016 22:59:45 +0000 Subject: [PATCH] started command line interface --- Makefile | 14 ++++++++++---- src/command.ml | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/command.ml diff --git a/Makefile b/Makefile index 478d334..8a53889 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,18 @@ OCB_FLAGS = -use-ocamlfind -I src # -I lib OCB = ocamlbuild $(OCB_FLAGS) -PKGS = toml,uuidm,opium.unix,omd,str,batteries,tyxml,lens,ptime,ptime.clock.os,re.str,lens.ppx_deriving,mustache +PKGS = toml,uuidm,omd,str,batteries,lens,ptime,ptime.clock.os,re.str,lens.ppx_deriving +WEB_PKGS = $(PKGS),opium.unix,tyxml,mustache +CMD_PKGS = $(PKGS),cmdliner -all: web +all: cmd web web: - $(OCB) web.native -pkgs $(PKGS) - mv web.native web + $(OCB) web.native -pkgs $(WEB_PKGS) + mv web.native logarion-web + +cmd: + $(OCB) command.native -pkg $(CMD_PKGS) + mv command.native logarion style: sassc share/sass/main.sass > share/static/main.css diff --git a/src/command.ml b/src/command.ml new file mode 100644 index 0000000..2921e57 --- /dev/null +++ b/src/command.ml @@ -0,0 +1,24 @@ +open Cmdliner + +let info = + let doc = "Command based interface for a Logarion." in + let man = [ + `S "BUGS"; + `P "Submit bugs https://github.com/orbifx/logarion/issues."; + ] in + Term.info "logarion" ~version:"0.1.0" ~doc ~man + +let operation = + let doc = "Logarion operation" in + Arg.(value & pos 0 string "help" & info [] ~docv:"operation" ~doc) +let logarion operation = + match operation with + | "create" -> print_endline "create" + | _ -> print_endline "help" + +let logarion_term = + Term.(const logarion $ operation) + +let () = + match Term.eval (logarion_term, info) with + `Error _ -> exit 1 | _ -> exit 0