summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorAndor Penzes <andor.penzes@gmail.com>2016-06-25 23:30:55 +0200
committerAndor Penzes <andor.penzes@gmail.com>2016-06-25 23:30:55 +0200
commitac1bb0820fb3368bc902bf9d7b5d58ae0eeb2ec8 (patch)
tree0336a89d3c8d69ef19c89f4f6086f5e5acc5aa0d /tool
parente73ad1cbaca363323879e25bf0462eff486d26ad (diff)
Add '--version' argument.
The abortOption is used instead of the switch. The swtich is always parsed blocking the compiler' option in the alternative case. I did not want to do a serious refactor here.
Diffstat (limited to 'tool')
-rw-r--r--tool/Compiler.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/tool/Compiler.hs b/tool/Compiler.hs
index e3fdd7a3..20665ce7 100644
--- a/tool/Compiler.hs
+++ b/tool/Compiler.hs
@@ -11,7 +11,7 @@ import LambdaCube.Compiler
11addInfo i p = info (helper <*> p) i 11addInfo i p = info (helper <*> p) i
12 12
13main :: IO () 13main :: IO ()
14main = join $ execParser $ addInfo i $ subparser ( 14main = join $ execParser $ addInfo i $ versionOption <*> subparser (
15 command "compile" (addInfo (progDesc "compiles LambdaCube3D source to JSON IR") compile') 15 command "compile" (addInfo (progDesc "compiles LambdaCube3D source to JSON IR") compile')
16 <> command "parse" (addInfo (progDesc "parses LambdaCube3D source") $ parse 16 <> command "parse" (addInfo (progDesc "parses LambdaCube3D source") $ parse
17 <$> argument str (metavar "SOURCE_FILE") 17 <$> argument str (metavar "SOURCE_FILE")
@@ -33,7 +33,17 @@ main = join $ execParser $ addInfo i $ subparser (
33 33
34 i = fullDesc 34 i = fullDesc
35 <> progDesc "executes command (default to compile if no command is given)" 35 <> progDesc "executes command (default to compile if no command is given)"
36 <> header ("LambdaCube 3D compiler " ++ showVersion version) 36 <> header versionStr
37
38versionStr :: String
39versionStr = "LambdaCube 3D compiler " ++ showVersion version
40
41versionOption :: Parser (a -> a)
42versionOption = abortOption (InfoMsg versionStr) $ mconcat
43 [ long "version"
44 , short 'v'
45 , help "Print version."
46 ]
37 47
38prettyPrint srcName output = do 48prettyPrint srcName output = do
39 let baseName = dropExtension srcName 49 let baseName = dropExtension srcName