hoogle-index 0.2.1 → 0.2.2
raw patch · 2 files changed
+42/−12 lines, 2 filesdep +optparse-applicativedep ~basedep ~transformers
Dependencies added: optparse-applicative
Dependency ranges changed: base, transformers
Files
- Main.hs +37/−8
- hoogle-index.cabal +5/−4
Main.hs view
@@ -16,10 +16,12 @@ import Data.Either (partitionEithers) import Control.Error +import Options.Applicative+ import qualified Data.ByteString.Char8 as BS import System.IO.Temp -import Distribution.Verbosity (Verbosity, normal)+import Distribution.Verbosity (Verbosity, normal, verbose) import Distribution.Simple.Compiler (Compiler (compilerId), compilerFlavor) import Distribution.Simple.GHC import Distribution.Simple.Program (defaultProgramConfiguration)@@ -38,13 +40,30 @@ , installTextBase :: Bool , useLocalDocs :: Bool , ignoreExistingTextBases :: Bool+ , otherPackageDbs :: [PackageDB] } -config = Config { verbosity = normal- , installTextBase = True- , useLocalDocs = True- , ignoreExistingTextBases = False- }+opts =+ Config <$> flag normal verbose+ ( short 'v' <> long "verbose"+ <> help "Enable verbose output"+ )+ <*> switch+ ( short 'i' <> long "install"+ <> help "Install generated textbases for future use"+ )+ <*> switch+ ( short 'l' <> long "local"+ <> help "Use local Haddock documentation when available"+ )+ <*> switch+ ( long "ignore-existing"+ <> help "Always regenerate textbases even if one already exists"+ )+ <*> many (option (fmap SpecificPackageDB . pure)+ ( short 'f' <> long "package-db"+ <> help "Add an addition package database (e.g. a Cabal sandbox)"+ )) -- | An unpacked Cabal project newtype PackageTree = PkgTree FilePath@@ -125,6 +144,9 @@ tbPath = docRoot </> name++".txt" liftIO $ putStrLn $ "Installing textbase to "++tbPath liftIO $ BS.writeFile tbPath content+ Nothing | installTextBase cfg -> do+ liftIO $ putStrLn $ "Can't install textbase due to missing documentation directory"+ _ -> return () return tb where pkg = sourcePackageId ipkg@@ -195,11 +217,18 @@ main :: IO () main = do+ config <- execParser+ $ info (helper <*> opts)+ ( fullDesc+ <> progDesc "Generate Hoogle indexes for locally install packages"+ <> header "hoogle-index - Painless local Hoogle indexing"+ )+ (compiler, _, progCfg) <- configure (verbosity config) Nothing Nothing defaultProgramConfiguration- pkgIdx <- getInstalledPackages (verbosity config)- [GlobalPackageDB, UserPackageDB] progCfg+ let pkgDbs = [GlobalPackageDB, UserPackageDB] ++ otherPackageDbs config+ pkgIdx <- getInstalledPackages (verbosity config) pkgDbs progCfg let pkgs = reverseTopologicalOrder pkgIdx maybeIndex :: InstalledPackageInfo -> IO (Either (PackageId, String) Database) maybeIndex pkg = runEitherT $ fmapLT (sourcePackageId pkg,)
hoogle-index.cabal view
@@ -1,5 +1,5 @@ name: hoogle-index-version: 0.2.1+version: 0.2.2 synopsis: Easily generate Hoogle indices for installed packages description: Easily generate Hoogle indices for installed packages homepage: http://github.com/bgamari/hoogle-index@@ -19,13 +19,14 @@ executable hoogle-index main-is: Main.hs other-extensions: TupleSections- build-depends: base >=4.7 && <4.8,- transformers >=0.4 && <0.5,+ build-depends: base >=4.6 && <4.8,+ transformers >=0.3 && <0.5, directory >=1.2 && <1.3, process >=1.2 && <1.3, filepath >=1.3 && <1.4, errors >=1.4 && <1.5, bytestring >=0.9 && <1.11, temporary >=1.2 && <1.3,- Cabal >=1.20 && <1.21+ Cabal >=1.20 && <1.21,+ optparse-applicative >=0.10 && <0.11 default-language: Haskell2010