From ebfc8be95e83852081d8dc93d2bf4717df18583e Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 22 Dec 2021 21:45:45 +0100 Subject: print version information on --version If --version is given, `walint` prints version information, then exists with code 0. --- src/Version.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/Version.hs (limited to 'src/Version.hs') diff --git a/src/Version.hs b/src/Version.hs new file mode 100644 index 0000000..6679ae1 --- /dev/null +++ b/src/Version.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TemplateHaskell #-} + + +module Version ( version ) where + +import Control.Monad.Trans (liftIO) +import qualified Language.Haskell.TH as TH +import System.Process (readProcess) + +version :: String +version = "walint rc3 2021 (" <> + $(do + hash <- liftIO $ readProcess "git" ["rev-parse", "HEAD"] "" + pure . TH.LitE . TH.StringL $ take 40 hash) ++ + ")" -- cgit v1.2.3