diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 65ce6ff..1fe41be 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -186,6 +186,21 @@ Executable ghc-modi , ghc , ghc-mod +Executable cabal-helper + Default-Language: Haskell2010 + Main-Is: GHCModCabal.hs + GHC-Options: -Wall + HS-Source-Dirs: src + X-Install-Target: $libexecdir + Build-Depends: base >= 4.0 && < 5 + , bytestring + , binary + , directory + if flag(cabal-122) + Build-Depends: Cabal >= 1.22 + else + Buildable: False + Test-Suite doctest Type: exitcode-stdio-1.0 Default-Language: Haskell2010 diff --git a/src/GHCModCabal.hs b/src/GHCModCabal.hs new file mode 100644 index 0000000..5aec6d9 --- /dev/null +++ b/src/GHCModCabal.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE BangPatterns #-} +module Main where + +import Control.Applicative + +import Distribution.Simple.Utils (cabalVersion) +import Distribution.Simple.Configure +import Distribution.Text ( display ) +import System.Environment +import System.Directory + +main :: IO () +main = do + args <- getArgs + case args of + "version":[] -> do + putStrLn $ "using version " ++ display cabalVersion ++ " of the Cabal library" + "print-setup-config":args' -> do + mfile <- findFile ["dist"] "setup-config" + + let file = case mfile of + Just f -> f + Nothing -> let !(f:[]) = args' in f + + putStrLn =<< show <$> getConfigStateFile file + + cmd:_ -> error $ "Unknown command: " ++ cmd + [] -> error "No command given"