forked from deepin-community/haskell-devscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetCabalVersion.hs
More file actions
28 lines (24 loc) · 846 Bytes
/
Copy pathGetCabalVersion.hs
File metadata and controls
28 lines (24 loc) · 846 Bytes
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
{-# LANGUAGE CPP #-}
import Distribution.PackageDescription (package, packageDescription)
#if __GLASGOW_HASKELL__ < 904
import Distribution.PackageDescription.Parsec (readGenericPackageDescription)
#else
import Distribution.Simple.PackageDescription (readGenericPackageDescription)
#endif
import Distribution.Pretty (prettyShow)
import Distribution.Types.PackageId (PackageIdentifier, pkgVersion)
import Distribution.Verbosity (silent)
import System.Environment (getArgs)
getPackageId :: IO PackageIdentifier
getPackageId = do
args <- getArgs
gpd <- readGenericPackageDescription silent (head args)
return $ package $ packageDescription gpd
packageVersion :: PackageIdentifier -> String
packageVersion =
prettyShow . pkgVersion
main :: IO ()
main = do
pkgid <- getPackageId
putStrLn $ packageVersion pkgid
return ()