Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --numeric-version and --ghc-numeric-version #158

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Help.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Help (
usage
, printVersion
, printNumericVersion
, printGhcNumericVersion
) where

import Paths_doctest (version)
Expand All @@ -18,10 +20,20 @@ usage = unlines [
, "Options:"
, " --help display this help and exit"
, " --version output version information and exit"
, " --numeric-version"
, " output just the version"
, " --ghc-numeric-version"
, " output the ghc version identical to ghc --numeric-version"
]

printVersion :: IO ()
printVersion = do
putStrLn ("doctest version " ++ showVersion version)
putStrLn ("using version " ++ GHC.cProjectVersion ++ " of the GHC API")
putStrLn ("using " ++ ghc)

printNumericVersion :: IO ()
printNumericVersion = putStrLn (showVersion version)

printGhcNumericVersion :: IO ()
printGhcNumericVersion = putStrLn GHC.cProjectVersion
6 changes: 4 additions & 2 deletions src/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ import qualified Interpreter
-- inside of it, ignoring hidden entries.
doctest :: [String] -> IO ()
doctest args0
| "--help" `elem` args0 = putStr usage
| "--version" `elem` args0 = printVersion
| "--help" `elem` args0 = putStr usage
| "--version" `elem` args0 = printVersion
| "--numeric-version" `elem` args0 = printNumericVersion
| "--ghc-numeric-version" `elem` args0 = printGhcNumericVersion
| otherwise = do
args <- concat <$> mapM expandDirs args0
i <- Interpreter.interpreterSupported
Expand Down