Browse files

Allow invoking 'hc-pkg init' via D.S.Program.HcPkg.

  • Loading branch information...
1 parent 30d6773 commit 1cc6878080f43fb223d752fe510785403e49ae8d @23Skidoo committed Aug 5, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 Cabal/Distribution/Simple/Program/HcPkg.hs
View
20 Cabal/Distribution/Simple/Program/HcPkg.hs
@@ -10,6 +10,7 @@
-- Currently only GHC and LHC have hc-pkg programs.
module Distribution.Simple.Program.HcPkg (
+ init,
register,
reregister,
unregister,
@@ -18,6 +19,7 @@ module Distribution.Simple.Program.HcPkg (
dump,
-- * Program invocations
+ initInvocation,
registerInvocation,
reregisterInvocation,
unregisterInvocation,
@@ -26,6 +28,7 @@ module Distribution.Simple.Program.HcPkg (
dumpInvocation,
) where
+import Prelude hiding (init)
import Distribution.Package
( PackageId, InstalledPackageId(..) )
import Distribution.InstalledPackageInfo
@@ -62,6 +65,15 @@ import System.FilePath as FilePath
import qualified System.FilePath.Posix as FilePath.Posix
+-- | Call @hc-pkg@ to initialise a package database at the location {path}.
+--
+-- > hc-pkg init {path}
+--
+init :: Verbosity -> ConfiguredProgram -> FilePath -> IO ()
+init verbosity hcPkg path =
+ runProgramInvocation verbosity
+ (initInvocation hcPkg verbosity path)
+
-- | Call @hc-pkg@ to register a package.
--
-- > hc-pkg register {filename | -} [--user | --global | --package-db]
@@ -228,6 +240,14 @@ setInstalledPackageId pkginfo = pkginfo
-- The program invocations
--
+initInvocation :: ConfiguredProgram
+ -> Verbosity -> FilePath -> ProgramInvocation
+initInvocation hcPkg verbosity path =
+ programInvocation hcPkg args
+ where
+ args = ["init", path]
+ ++ verbosityOpts hcPkg verbosity
+
registerInvocation, reregisterInvocation
:: ConfiguredProgram -> Verbosity -> PackageDBStack
-> Either FilePath InstalledPackageInfo

1 comment on commit 1cc6878

@tibbe

LGTM

Please sign in to comment.