Changes ArgParser to read info from cabal file.
parent
c5e7fd0683
commit
835e30ca97
|
@ -0,0 +1,29 @@
|
||||||
|
module Distribution.CurrentPackageDescription
|
||||||
|
( currentPackageDescription
|
||||||
|
, getField
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Distribution.PackageDescription
|
||||||
|
import Distribution.PackageDescription.Parse
|
||||||
|
import Distribution.Verbosity
|
||||||
|
|
||||||
|
import Data.List (isSuffixOf)
|
||||||
|
import Language.Haskell.TH (stringE, runIO, Q, Exp)
|
||||||
|
import System.Directory (getCurrentDirectory, getDirectoryContents)
|
||||||
|
|
||||||
|
|
||||||
|
getField :: (PackageDescription -> String) -> Q Exp
|
||||||
|
getField f = runIO currentPackageDescription >>= stringE . f
|
||||||
|
|
||||||
|
currentPackageDescription :: IO PackageDescription
|
||||||
|
currentPackageDescription = fmap packageDescription $ do
|
||||||
|
dir <- getCurrentDirectory
|
||||||
|
cs <- cabalFiles dir
|
||||||
|
case cs of
|
||||||
|
(c:_) -> readPackageDescription silent c
|
||||||
|
[] -> error $ "Couldn't find a cabal file in the current working directory (" ++ dir ++ ")"
|
||||||
|
|
||||||
|
cabalFiles :: FilePath -> IO [FilePath]
|
||||||
|
cabalFiles dir = do
|
||||||
|
files <- getDirectoryContents dir
|
||||||
|
return $ filter (".cabal" `isSuffixOf`) files
|
|
@ -1,15 +1,17 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
module Ringo.ArgParser (ProgArgs(..), parseArgs) where
|
module Ringo.ArgParser (ProgArgs(..), parseArgs) where
|
||||||
|
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
|
import qualified Distribution.Package as P
|
||||||
|
import qualified Distribution.PackageDescription as P
|
||||||
|
import qualified Distribution.CurrentPackageDescription as P
|
||||||
|
import qualified Distribution.Text as DText
|
||||||
|
|
||||||
import Data.List (intercalate)
|
import Data.List (intercalate)
|
||||||
import Data.Version (showVersion)
|
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
|
||||||
import Paths_ringo (version)
|
|
||||||
|
|
||||||
import Ringo.Types
|
import Ringo.Types
|
||||||
|
|
||||||
data ProgArgs = ProgArgs
|
data ProgArgs = ProgArgs
|
||||||
|
@ -98,15 +100,20 @@ progArgsParser =
|
||||||
<> action "directory"
|
<> action "directory"
|
||||||
<> help "Output directory")
|
<> help "Output directory")
|
||||||
|
|
||||||
|
progName :: String
|
||||||
|
progName = $(P.getField (DText.display . P.pkgName . P.package))
|
||||||
|
|
||||||
versionParser :: Parser (a -> a)
|
versionParser :: Parser (a -> a)
|
||||||
versionParser = infoOption ("ringo " ++ showVersion version)
|
versionParser = infoOption (progName ++ " " ++ version)
|
||||||
(long "version"
|
(long "version"
|
||||||
<> help "Print version information")
|
<> help "Print version information")
|
||||||
|
where
|
||||||
|
version = $(P.getField (DText.display . P.pkgVersion . P.package))
|
||||||
|
|
||||||
parseArgs :: IO ProgArgs
|
parseArgs :: IO ProgArgs
|
||||||
parseArgs = execParser $
|
parseArgs = execParser $
|
||||||
info (helper <*> versionParser <*> progArgsParser)
|
info (helper <*> versionParser <*> progArgsParser)
|
||||||
(fullDesc
|
(fullDesc
|
||||||
<> progDesc "Transforms OLTP database schemas to OLAP database star schemas"
|
<> progDesc $(P.getField P.description)
|
||||||
<> header "ringo - OLTP to OLAP schema transformer"
|
<> header (progName ++ " - " ++ $(P.getField P.synopsis))
|
||||||
<> footer "Source: http://github.com/quintype/ringo")
|
<> footer ("© " ++ $(P.getField P.copyright) ++ ". " ++ $(P.getField P.homepage)))
|
||||||
|
|
13
ringo.cabal
13
ringo.cabal
|
@ -1,13 +1,13 @@
|
||||||
name: ringo
|
name: ringo
|
||||||
version: 0.1.0.0
|
version: 0.1.0.0
|
||||||
synopsis: Tool to transform OLTP schemas to OLAP star schemas automatically
|
synopsis: OLTP to OLAP schema transformer
|
||||||
description: Please see README.md
|
description: Tool to transform OLTP schemas to OLAP star schemas automatically
|
||||||
homepage: http://github.com/quintype/ringo#readme
|
homepage: http://github.com/quintype/ringo
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Abhinav Sarkar
|
author: Abhinav Sarkar
|
||||||
maintainer: abhinav@abhinavsarkar.net
|
maintainer: abhinav@abhinavsarkar.net
|
||||||
copyright: 2015 Quintype Inc, Nilenso Software LLP
|
copyright: 2015-2016 Quintype Inc, Nilenso Software LLP
|
||||||
category: SQL
|
category: SQL
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
-- extra-source-files:
|
-- extra-source-files:
|
||||||
|
@ -41,7 +41,8 @@ library
|
||||||
executable ringo
|
executable ringo
|
||||||
hs-source-dirs: app
|
hs-source-dirs: app
|
||||||
other-modules: Ringo.ArgParser,
|
other-modules: Ringo.ArgParser,
|
||||||
Ringo.InputParser
|
Ringo.InputParser,
|
||||||
|
Distribution.CurrentPackageDescription
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
build-depends: base >=4.7 && <5,
|
build-depends: base >=4.7 && <5,
|
||||||
text >=1.2 && <1.3,
|
text >=1.2 && <1.3,
|
||||||
|
@ -53,6 +54,8 @@ executable ringo
|
||||||
directory >=1.2 && <1.3,
|
directory >=1.2 && <1.3,
|
||||||
filepath >=1.3 && <1.5,
|
filepath >=1.3 && <1.5,
|
||||||
aeson >=0.8 && <0.12,
|
aeson >=0.8 && <0.12,
|
||||||
|
Cabal >=1.18 && <1.23,
|
||||||
|
template-haskell >=2.9 && <2.11,
|
||||||
ringo
|
ringo
|
||||||
ghc-options: -Wall -Werror -fwarn-incomplete-uni-patterns -fno-warn-unused-do-bind
|
ghc-options: -Wall -Werror -fwarn-incomplete-uni-patterns -fno-warn-unused-do-bind
|
||||||
-fno-warn-orphans -funbox-strict-fields -O2
|
-fno-warn-orphans -funbox-strict-fields -O2
|
||||||
|
|
Loading…
Reference in New Issue