cabalish 0.1.0.1 → 0.1.0.2
raw patch · 2 files changed
+15/−13 lines, 2 files
Files
- cabalish.cabal +2/−2
- src/Main.hs +13/−11
cabalish.cabal view
@@ -1,5 +1,5 @@ name: cabalish-version: 0.1.0.1+version: 0.1.0.2 synopsis: Provides access to the cabal file data for shell scripts description: Use "cabalish name" to get the name from the local cabal file in a shell script, or "cabalish version" to get the version from the local cabal file in a shell script. homepage: https://github.com/RobertFischer/cabalish#readme@@ -17,7 +17,7 @@ hs-source-dirs: src main-is: Main.hs default-language: Haskell2010- ghc-options: -O3 -Wall+ ghc-options: -O3 -Wall +RTS -G1 -qg -qb -ki32k -RTS build-depends: base >= 4.7 && < 5 , optparse-applicative >= 0.13.2.0 && < 0.14 , classy-prelude >= 1.2.0.1 && < 2
src/Main.hs view
@@ -16,22 +16,24 @@ run :: RunOpts -> IO () run opts = case optCommand opts of- FetchName fetchOpts -> runFetchName filepath fetchOpts- FetchVersion fetchOpts -> runFetchVersion filepath fetchOpts+ FetchName _ -> runFetchName filepath+ FetchVersion _ -> runFetchVersion filepath where filepath = optFilepath opts -runFetchName :: FilePath -> FetchNameOpts -> IO ()-runFetchName filepath _ = do+fromPkgDesc :: (PackageDescription -> String) -> FilePath -> IO ()+fromPkgDesc f filepath = do pkgDesc <- readCabalFile filepath- let name = unPackageName $ pkgName $ package pkgDesc- putStr $ T.pack name+ let result = f pkgDesc+ putStr $ T.pack result -runFetchVersion :: FilePath -> FetchVersionOpts -> IO ()-runFetchVersion filepath _ = do- pkgDesc <- readCabalFile filepath- let version = intercalate "." $ map show $ versionBranch $ pkgVersion $ package pkgDesc- putStr $ T.pack version+runFetchName :: FilePath -> IO ()+runFetchName = fromPkgDesc $ \pkgDesc ->+ unPackageName $ pkgName $ package pkgDesc++runFetchVersion :: FilePath -> IO ()+runFetchVersion = fromPkgDesc $ \pkgDesc ->+ intercalate "." $ map show $ versionBranch $ pkgVersion $ package pkgDesc readCabalFile :: FilePath -> IO PackageDescription readCabalFile filepath = packageDescription <$> readPackageDescription verbose filepath