Commit a70ae834 authored by Nicholas Luo's avatar Nicholas Luo

Remove help check from parseFlags (redundant), add version check in...

Remove help check from parseFlags (redundant), add version check in parseFlags, add CPP flag to access VERSION_python_kernel in Flags.hs
parent d1c84ee2
{-# LANGUAGE NoImplicitPrelude, DeriveFunctor #-}
{-# LANGUAGE CPP, NoImplicitPrelude, DeriveFunctor #-}
module IHaskell.Flags (
IHaskellMode(..),
......@@ -32,6 +32,7 @@ data Argument = ConfFile String -- ^ A file with commands to load at startup
| GhcLibDir String -- ^ Where to find the GHC libraries.
| KernelDebug -- ^ Spew debugging output from the kernel.
| Help -- ^ Display help text.
| Version -- ^ Display version text.
| ConvertFrom String
| ConvertTo String
| ConvertFromFormat NotebookFormat
......@@ -70,8 +71,8 @@ parseFlags flags =
in case modeIndex of
Nothing ->
-- Treat no mode as 'console'.
if "--help" `elem` flags
then Left $ showText (Wrap 100) $ helpText [] HelpFormatAll ihaskellArgs
if "--version" `elem` flags || "-V" `elem` flags
then Left VERSION_ipython_kernel
else process ihaskellArgs flags
Just 0 -> process ihaskellArgs flags
......@@ -177,10 +178,12 @@ lhsStyleTex = LhsStyle "" "" "\\begin{code}" "\\end{code}" "\\begin{verbatim}" "
ihaskellArgs :: Mode Args
ihaskellArgs =
let descr = "Haskell for Interactive Computing."
let noMode = mode "IHaskell" defaultReport descr noArgs [helpFlag, versionFlag]
defaultReport = Args (ShowHelp helpStr) []
descr = "Haskell for Interactive Computing."
helpFlag = flagHelpSimple (add Help)
versionFlag = flagVersion (add Version)
helpStr = showText (Wrap 100) $ helpText [] HelpFormatAll ihaskellArgs
onlyHelp = [flagHelpSimple (add Help)]
noMode = mode "IHaskell" (Args (ShowHelp helpStr) []) descr noArgs onlyHelp
in noMode { modeGroupModes = toGroup allModes }
where
add flag (Args mode flags) = Args mode $ flag : flags
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment