diff options
author | Ian Lynagh <igloo@earth.li> | 2009-03-05 16:20:45 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2009-03-05 16:20:45 +0000 |
commit | bb57db143d9c0207e4c2c4c24ceb688714c2980d (patch) | |
tree | d1d0d00ebc96785b33370c3493bfed5bbfa2ec9b /utils/runghc | |
parent | 8ffd91b6102f4ad3111cabdf6bdb1998f257887f (diff) | |
download | haskell-bb57db143d9c0207e4c2c4c24ceb688714c2980d.tar.gz |
Add --version to runghc. Trac #2757.
We use the GHC version number, as the old runghc one doesn't seem very
useful.
Diffstat (limited to 'utils/runghc')
-rw-r--r-- | utils/runghc/Makefile | 3 | ||||
-rw-r--r-- | utils/runghc/runghc.cabal.in (renamed from utils/runghc/runghc.cabal) | 3 | ||||
-rw-r--r-- | utils/runghc/runghc.hs | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/utils/runghc/Makefile b/utils/runghc/Makefile index 0b606de638..1415921b04 100644 --- a/utils/runghc/Makefile +++ b/utils/runghc/Makefile @@ -5,5 +5,8 @@ ENABLE_SHELL_WRAPPERS = YES include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/cabal.mk +distclean maintainer-clean: + $(RM) -f runghc.cabal + # XXX Need to make runhaskell somehow diff --git a/utils/runghc/runghc.cabal b/utils/runghc/runghc.cabal.in index 876e97d41a..7b3fc1b13a 100644 --- a/utils/runghc/runghc.cabal +++ b/utils/runghc/runghc.cabal.in @@ -1,6 +1,5 @@ Name: runghc --- XXX version number: -Version: 0.67 +Version: @ProjectVersion@ Copyright: XXX License: BSD3 -- XXX License-File: LICENSE diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index bfdcc96b3a..47615def3a 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -22,10 +22,13 @@ module Main (main) where +import Paths_runghc + import Control.Exception import Data.Char import Data.List import Data.Monoid +import Data.Version import System.Cmd import System.Directory import System.Environment @@ -44,6 +47,7 @@ main = do args <- getArgs case parseRunGhcFlags args of (Help, _) -> printUsage + (ShowVersion, _) -> printVersion (RunGhcFlags (Just ghc), args') -> doIt ghc args' (RunGhcFlags Nothing, args') -> do mbPath <- getExecPath @@ -55,11 +59,14 @@ main = do data RunGhcFlags = RunGhcFlags (Maybe FilePath) -- GHC location | Help -- Print help text + | ShowVersion -- Print version info instance Monoid RunGhcFlags where mempty = RunGhcFlags Nothing Help `mappend` _ = Help _ `mappend` Help = Help + ShowVersion `mappend` _ = ShowVersion + _ `mappend` ShowVersion = ShowVersion RunGhcFlags _ `mappend` right@(RunGhcFlags (Just _)) = right left@(RunGhcFlags _) `mappend` RunGhcFlags Nothing = left @@ -70,11 +77,16 @@ parseRunGhcFlags = f mempty f flags (('-' : 'f' : ghc) : args) = f (flags `mappend` RunGhcFlags (Just ghc)) args f flags ("--help" : args) = f (flags `mappend` Help) args + f flags ("--version" : args) = f (flags `mappend` ShowVersion) args -- If you need the first GHC flag to be a -f flag then -- you can pass -- first f flags ("--" : args) = (flags, args) f flags args = (flags, args) +printVersion :: IO () +printVersion = do + putStrLn ("runghc " ++ showVersion version) + printUsage :: IO () printUsage = do putStrLn "Usage: runghc [runghc flags] [GHC flags] module [program args]" @@ -82,6 +94,7 @@ printUsage = do putStrLn "The runghc flags are" putStrLn " -f /path/to/ghc Tell runghc where GHC is" putStrLn " --help Print this usage information" + putStrLn " --version Print version number" doIt :: String -> [String] -> IO () doIt ghc args = do |