summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmchale <>2018-12-03 04:47:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-12-03 04:47:00 (GMT)
commit7e325266654ae5e3f9d192a619ed795c354e81a1 (patch)
tree753b5bb70eb8c6c28bf2e4840507c2e917559084
parent1cf337f86ab8840c718cc7d209e708aeeea0184b (diff)
version 0.1.0.380.1.0.38
-rw-r--r--CHANGELOG.md4
-rw-r--r--README.md2
-rw-r--r--app/Main.hs50
-rwxr-xr-xcabal.project (renamed from cabal.project.local)2
-rw-r--r--tomlcheck.cabal17
5 files changed, 45 insertions, 30 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..c5552ea
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,4 @@
+# 0.1.0.38
+
+ * Remove dependency on `optparse-generic` as it has spurious dependencies and
+ breaks cross-compilation
diff --git a/README.md b/README.md
index ca5c91a..f6873fe 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ Install [GHC](https://www.haskell.org/ghc/download.html) along with
### Travis
-Add the following your `.travis.yml` file to check a `.toml` file:
+Add the following your `.travis.yml` file to check a file called `Config.toml`:
```yaml
- curl -sL https://raw.githubusercontent.com/vmchale/tomlcheck/master/sh/check | sh -s Config.toml
diff --git a/app/Main.hs b/app/Main.hs
index 472e079..bfeea71 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -1,36 +1,42 @@
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE TypeOperators #-}
-
module Main
( main
) where
import Control.Monad
-import qualified Data.Text.IO as TIO
-import GHC.Generics (Generic)
-import Options.Generic
-import System.Exit (ExitCode (..), exitWith)
-import Text.Megaparsec (errorBundlePretty)
-import Text.Toml (parseTomlDoc)
+import qualified Data.Text.IO as TIO
+import Data.Version (showVersion)
+import Options.Applicative
+import Paths_tomlcheck (version)
+import System.Exit (ExitCode (..), exitWith)
+import Text.Megaparsec (errorBundlePretty)
+import Text.Toml (parseTomlDoc)
-newtype Program = Program { file :: [FilePath] <?> "Path to file to be checked." }
- deriving (Generic)
+versionInfo :: Parser (a -> a)
+versionInfo = infoOption ("tomlcheck version: " ++ showVersion version) (short 'V' <> long "version" <> help "Show version")
-programModifiers :: Modifiers
-programModifiers = defaultModifiers { shortNameModifier = firstLetter }
+tomlFile :: Parser [FilePath]
+tomlFile = some
+ (strOption
+ (metavar "FILE"
+ <> long "file"
+ <> short 'f'
+ <> help "Path to file to be checked"
+ ))
-instance ParseRecord Program where
- parseRecord = parseRecordWithModifiers programModifiers
+wrapper :: ParserInfo [FilePath]
+wrapper = info (helper <*> versionInfo <*> tomlFile)
+ (fullDesc
+ <> progDesc "A TOML syntax checker"
+ <> header "tomlcheck - a syntax checker for TOML written in Haskell")
main :: IO ()
-main = do
- x <- getRecord "Command-line wrapper around htoml"
- let paths = unHelpful $ file x
+main = execParser wrapper >>= run
+
+run :: [FilePath] -> IO ()
+run paths = do
contents <- traverse TIO.readFile paths
case zipWithM parseTomlDoc paths contents of
- Right _ -> mempty
- Left e -> do
+ Right{} -> mempty
+ Left e -> do
putStrLn $ errorBundlePretty e
exitWith (ExitFailure 1)
diff --git a/cabal.project.local b/cabal.project
index 841bf2b..f5cc38b 100755
--- a/cabal.project.local
+++ b/cabal.project
@@ -1,2 +1,2 @@
-optimization: 2
+packages: ./
constraints: tomlcheck +development
diff --git a/tomlcheck.cabal b/tomlcheck.cabal
index b7b9255..71b119f 100644
--- a/tomlcheck.cabal
+++ b/tomlcheck.cabal
@@ -1,6 +1,6 @@
cabal-version: 1.18
name: tomlcheck
-version: 0.1.0.36
+version: 0.1.0.38
license: BSD3
license-file: LICENSE
copyright: Copyright: (c) 2017-2018 Vanessa McHale
@@ -14,8 +14,9 @@ description:
category: Toml, Data
build-type: Simple
extra-source-files:
- cabal.project.local
+ cabal.project
extra-doc-files: README.md
+ CHANGELOG.md
source-repository head
type: git
@@ -30,6 +31,10 @@ flag development
executable tomlcheck
main-is: Main.hs
hs-source-dirs: app
+ other-modules:
+ Paths_tomlcheck
+ autogen-modules:
+ Paths_tomlcheck
default-language: Haskell2010
other-extensions: DataKinds DeriveGeneric OverloadedStrings
TypeOperators
@@ -37,15 +42,15 @@ executable tomlcheck
build-depends:
base >=4.9 && <5,
htoml-megaparsec >=2.1.0.0,
- optparse-generic -any,
+ optparse-applicative -any,
megaparsec >=7.0,
text -any
-
+
if flag(development)
ghc-options: -Werror
-
+
if impl(ghc >=8.0)
ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates
-
+
if impl(ghc >=8.4)
ghc-options: -Wmissing-export-lists