From e91483360042e37c309d7d2a07e45ee182311d23 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Sat, 7 Dec 2019 08:11:33 -0600 Subject: [PATCH] Add --version via dune rule --- src/bin/cli.ml | 9 ++++++++- src/bin/dune | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index a9376ca9d..13cb7f761 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -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 diff --git a/src/bin/dune b/src/bin/dune index 5a2c5efd3..4546f2a6f 100644 --- a/src/bin/dune +++ b/src/bin/dune @@ -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)