Add --version via dune rule

This commit is contained in:
Tom Jack 2019-12-07 08:11:33 -06:00
parent 32d53cf9e6
commit e914833600
2 changed files with 16 additions and 2 deletions

View File

@ -2,11 +2,18 @@ open Cmdliner
open Trace
open Cli_helpers
let version =
Format.asprintf
"Rolling release\nHash: %s\nDate: %s\nCI job id: %s"
Version.hash
Version.commit_date
Version.job_id
let main =
let man =
[ `S "MORE HELP";
`P "Use `$(mname) $(i,COMMAND) --help' for help on a single command." ] in
(Term.(ret (const (`Help (`Auto, None)))), Term.info "ligo" ~man)
(Term.(ret (const (`Help (`Auto, None)))), Term.info "ligo" ~version ~man)
let source_file n =
let open Arg in

View File

@ -5,13 +5,20 @@
cmdliner
ligo
)
(modules cli cli_helpers)
(modules cli cli_helpers version)
(preprocess
(pps ppx_let)
)
(flags (:standard -open Simple_utils))
)
(rule
(targets version.ml)
(action (with-stdout-to
version.ml
(run "sh" "-c"
"printf 'let hash = \"%s\"\nlet commit_date = \"%s\"\nlet job_id = \"%s\"\n' \"$(git rev-parse HEAD)\" \"$(git show --no-patch --format=%ci)\" \"${CI_JOB_ID}\""))))
(executable
(name runligo)
(public_name ligo)