diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 11 | ||||
-rw-r--r-- | src/Version.hs | 15 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs index 32afb6a..9bc09ff 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -12,17 +12,19 @@ import Data.Aeson (eitherDecode, encode) import Data.Aeson.Encode.Pretty (encodePretty) import Data.Aeson.KeyMap (coercionToHashMap) import qualified Data.ByteString.Lazy as LB -import qualified Data.Text.Encoding as T -import qualified Data.Text.IO as T import Data.Maybe (fromMaybe) +import qualified Data.Text.Encoding as T +import qualified Data.Text.IO as T import System.Exit (ExitCode (..), exitWith) import WithCli import CheckDir (recursiveCheckDir, resultIsFatal) +import Control.Monad (when) import LintConfig (LintConfig (..), patchConfig) import System.IO (hPutStrLn, stderr) import Types (Level (..)) import Util (printPretty) +import qualified Version as V (version) import WriteRepo (writeAdjustedRepository) -- | the options this cli tool can take @@ -43,6 +45,7 @@ data Options = Options -- ^ path to a config file. Currently required. , config :: Maybe (LintConfig Maybe) -- ^ a "patch" for the configuration file + , version :: Bool } deriving (Show, Generic, HasArguments) @@ -53,6 +56,10 @@ run :: Options -> IO () run options = do aesonWarning + when (version options) $ do + putStrLn V.version + exitWith ExitSuccess + let repo = fromMaybe "." (repository options) let entry = fromMaybe "main.json" (entrypoint options) let level = fromMaybe Suggestion (lintlevel options) 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) ++ + ")" |