Skip to content

Commit

Permalink
Add a :version command that prints the version.
Browse files Browse the repository at this point in the history
Fixes #859
  • Loading branch information
robdockins committed Aug 22, 2020
1 parent 8218795 commit 2c9a03c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Cryptol/REPL/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import Cryptol.Symbolic
)
import qualified Cryptol.Symbolic.SBV as SBV
import qualified Cryptol.Symbolic.What4 as W4
import Cryptol.Version (commitShortHash,commitDirty,version)

import qualified Control.Exception as X
import Control.Monad hiding (mapM, mapM)
Expand All @@ -101,6 +102,7 @@ import Data.Function (on)
import Data.List (intercalate, nub, sortBy, groupBy,
partition, isPrefixOf,intersperse)
import Data.Maybe (fromMaybe,mapMaybe,isNothing)
import Data.Version (showVersion)
import System.Environment (lookupEnv)
import System.Exit (ExitCode(ExitSuccess))
import System.Process (shell,createProcess,waitForProcess)
Expand Down Expand Up @@ -194,6 +196,9 @@ nbCommandList =
, CommandDescr [ ":b", ":browse" ] ["[ MODULE ]"] (ModNameArg browseCmd)
"Display environment for all loaded modules, or for a specific module."
""
, CommandDescr [ ":version"] [] (NoArg versionCmd)
"Display the version of this Cryptol executable"
""
, CommandDescr [ ":?", ":help" ] ["[ TOPIC ]"] (HelpArg helpCmd)
"Display a brief description of a function, type, or command. (e.g. :help :help)"
(unlines
Expand Down Expand Up @@ -1068,10 +1073,17 @@ loadHelper how =
M.InMem {} -> clearEditPath
setDynEnv mempty

versionCmd :: REPL ()
versionCmd = rPutStrLn versionText
where
hashText | commitShortHash == "UNKNOWN" = ""
| otherwise = " (" ++ commitShortHash ++
(if commitDirty then ", modified)" else ")")
versionText = "version " ++ showVersion version ++ hashText

quitCmd :: REPL ()
quitCmd = stop


browseCmd :: String -> REPL ()
browseCmd input = do
let mnames = map (M.textToModName . T.pack) (words input)
Expand Down

0 comments on commit 2c9a03c

Please sign in to comment.