aboutsummaryrefslogtreecommitdiff
path: root/CabalHelper/Wrapper.hs
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2015-09-24 04:51:50 +0200
committerDaniel Gröber <dxld@darkboxed.org>2015-09-24 04:51:50 +0200
commitc2f6a2e5bf40f9e4cb9276bcc9b58ec3627f727a (patch)
tree77dcdb7c884d32637464f858e0d980376d790f58 /CabalHelper/Wrapper.hs
parentf2bfb9bab04de16e94c8f959c1f5eebe82d6a0aa (diff)
Move package-id to wrapper
we need it before dist/setup-config exists so we can't run it as part of the other queries anyways, might as well go in the wrapper.
Diffstat (limited to 'CabalHelper/Wrapper.hs')
-rw-r--r--CabalHelper/Wrapper.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/CabalHelper/Wrapper.hs b/CabalHelper/Wrapper.hs
index 5cd3ef8..1987e6c 100644
--- a/CabalHelper/Wrapper.hs
+++ b/CabalHelper/Wrapper.hs
@@ -35,6 +35,9 @@ import Prelude
import Distribution.System (buildPlatform)
import Distribution.Text (display)
+import Distribution.Verbosity (silent, deafening)
+import Distribution.PackageDescription.Parse (readPackageDescription)
+import Distribution.Package (packageName, packageVersion)
import Paths_cabal_helper (version)
import CabalHelper.Common
@@ -56,7 +59,7 @@ usage = do
\ [--with-cabal=CABAL_PATH]\n\
\ [--with-cabal-version=VERSION]\n\
\ [--with-cabal-pkg-db=PKG_DB]\n\
-\ PROJ_DIR DIST_DIR ( print-exe | [CABAL_HELPER_ARGS...] ) )\n"
+\ PROJ_DIR DIST_DIR ( print-exe | package-id | [CABAL_HELPER_ARGS...] ) )\n"
globalArgSpec :: [OptDescr (Options -> Options)]
globalArgSpec =
@@ -116,6 +119,15 @@ main = handlePanic $ do
"version":[] -> putStrLn $ showVersion version
"print-appdatadir":[] -> putStrLn =<< appDataDir
"print-build-platform":[] -> putStrLn $ display buildPlatform
+
+ projdir:_distdir:"package-id":[] -> do
+ v <- maybe silent (const deafening) . lookup "GHC_MOD_DEBUG" <$> getEnvironment
+ -- ghc-mod will catch multiple cabal files existing before we get here
+ [cfile] <- filter isCabalFile <$> getDirectoryContents projdir
+ gpd <- readPackageDescription v (projdir </> cfile)
+ putStrLn $ show $
+ [Just $ ChResponseVersion (display (packageName gpd)) (packageVersion gpd)]
+
projdir:distdir:args' -> do
cfgf <- canonicalizePath (distdir </> "setup-config")
mhdr <- getCabalConfigHeader cfgf