packages feed

cabalish (empty) → 0.1.0.0

raw patch · 5 files changed

+98/−0 lines, 5 filesdep +Cabaldep +basedep +classy-preludesetup-changed

Dependencies added: Cabal, base, classy-prelude, directory, filepath, optparse-applicative, text

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Robert Fischer (c) 2017++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Robert Fischer nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,1 @@+# cabalish
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ cabalish.cabal view
@@ -0,0 +1,28 @@+name:                cabalish+version:             0.1.0.0+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+license:             BSD3+license-file:        LICENSE+author:              Robert Fischer+maintainer:          smokejumperit+stack@gmail.com+copyright:           (c)2017 Robert Fischer+category:            Utilities+build-type:          Simple+cabal-version:       >=1.10+extra-source-files:  README.md++executable cabalish+  hs-source-dirs:      src+  main-is:             Main.hs+  default-language:    Haskell2010+  ghc-options:         -O3 -Wall+  build-depends:       base >= 4.7 && < 5+                    ,  optparse-applicative >= 0.13.2.0 && < 0.14+                    ,  classy-prelude >= 1.2.0.1 && < 2+                    ,  filepath >= 1.4.1.1 && < 2+                    ,  directory >= 1.3.0.0 && < 2+                    ,  Cabal >= 1.24.2.0 && < 2+                    ,  text >= 1.2.2.1 && < 2+  --other-modules:       Arguments.hs
+ src/Main.hs view
@@ -0,0 +1,37 @@+module Main where++import Prelude ()+import ClassyPrelude+import Arguments+import System.FilePath (FilePath)+import Distribution.Package+import Distribution.PackageDescription+import Distribution.PackageDescription.Parse (readPackageDescription)+import Distribution.Version (Version(..))+import Distribution.Verbosity (verbose)+import qualified Data.Text as T++main :: IO ()+main = run =<< readOpts++run :: RunOpts -> IO ()+run opts = case optCommand opts of+             FetchName fetchOpts -> runFetchName filepath fetchOpts+             FetchVersion fetchOpts -> runFetchVersion filepath fetchOpts+  where+    filepath = optFilepath opts++runFetchName :: FilePath -> FetchNameOpts -> IO ()+runFetchName filepath _ = do+  pkgDesc <- readCabalFile filepath+  let name = unPackageName $ pkgName $ package pkgDesc+  putStr $ T.pack name++runFetchVersion :: FilePath -> FetchVersionOpts -> IO ()+runFetchVersion filepath _ = do+  pkgDesc <- readCabalFile filepath+  let version = intercalate "." $ map show $ versionBranch $ pkgVersion $ package pkgDesc+  putStr $ T.pack version++readCabalFile :: FilePath -> IO PackageDescription+readCabalFile filepath = packageDescription <$> readPackageDescription verbose filepath