-
Notifications
You must be signed in to change notification settings - Fork 123
/
Version.hs
60 lines (51 loc) · 1.95 KB
/
Version.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
module CryptolServer.Version
( version
, versionDescr
, VersionParams(..)
) where
import qualified Argo.Doc as Doc
import Data.Aeson as JSON
import qualified Paths_cryptol_remote_api as RPC
import qualified Cryptol.Version as Cry
import Data.Version (showVersion)
import CryptolServer
versionDescr :: Doc.Block
versionDescr =
Doc.Paragraph
[Doc.Text "Version information about this Cryptol server."]
version :: VersionParams -> CryptolCommand JSON.Value
version _ =
return $ JSON.object [ "RPC server version" .= showVersion RPC.version
, "version" .= showVersion Cry.version
, "commit hash" .= Cry.commitHash
, "commit branch" .= Cry.commitBranch
, "commit dirty" .= Cry.commitDirty
, "FFI enabled" .= Cry.ffiEnabled
]
data VersionParams = VersionParams
instance JSON.FromJSON VersionParams where
parseJSON _ = pure VersionParams
instance Doc.DescribedMethod VersionParams JSON.Value where
parameterFieldDescription = []
resultFieldDescription =
[ ("RPC server version",
Doc.Paragraph [ Doc.Text "The cryptol-remote-api version string."
])
, ("version",
Doc.Paragraph [ Doc.Text "The Cryptol version string."
])
, ("commit hash",
Doc.Paragraph [ Doc.Text "The string of the git commit hash during the build of Cryptol."
])
, ("commit branch",
Doc.Paragraph [ Doc.Text "The string of the git commit branch during the build of Cryptol."
])
, ("commit dirty",
Doc.Paragraph [ Doc.Text "True iff non-committed files were present during the build of Cryptol."
])
, ("FFI enabled",
Doc.Paragraph [ Doc.Text "True iff the FFI is enabled."
])
]