summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmchale <>2017-10-11 03:14:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-10-11 03:14:00 (GMT)
commitd5924a2704d95e4b5d559ec0e04868216240e0f6 (patch)
treef51fe1ad6f4ddef9a9c27251a272871e5d390004
version 0.1.0.00.1.0.0
-rw-r--r--.travis.yml57
-rw-r--r--LICENSE11
-rw-r--r--README.md24
-rw-r--r--Setup.hs2
-rw-r--r--app/Main.hs6
-rw-r--r--cabal.project.local2
-rw-r--r--src/Lib.hs32
-rw-r--r--stack.yaml9
-rw-r--r--tomlcheck.cabal57
9 files changed, 200 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7f974e7
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,57 @@
+---
+
+sudo: false
+language: default
+cache:
+ directories:
+ - $HOME/.stack
+addons:
+ apt:
+ packages:
+ - libgmp3-dev
+matrix:
+ include:
+
+ # Linux
+ - env: TARGET=x86_64-unkown-linux-gnu
+
+ # OS X
+ - env: TARGET=x86_64-apple-darwin
+ os: osx
+
+before_install:
+ - mkdir -p ~/.local/bin
+ - export PATH=$HOME/.local/bin:$PATH
+ - |
+ if [ `uname` = "Darwin" ]
+ then
+ curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
+ else
+ curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
+ fi
+ - chmod a+x ~/.local/bin/stack
+
+install:
+ - stack --no-terminal --install-ghc test --only-dependencies
+ - stack install hlint weeder
+
+script:
+ - stack --no-terminal build --haddock --no-haddock-deps
+ - hlint .
+ - weeder .
+ - export BINPATH="$(find -name tomlcheck -executable | tail -n2 | head -n1)"
+ - mv $BINPATH tomlcheck-$TARGET
+
+deploy:
+ api_key:
+ secure: "j9WeKTBKsnRmrUqBEVfX1itilQ2bfrBb7yIVir4BsBksmwkozc7eNpBFvBi+nAVyZrEouJUi3RSU4UMoO3otIqKPsRpC1pV5+GlNV1Q0yrVQn9+Xi4wzrinzWJuLrFUn3c1yhUAue/XTTBDS7IZHUYRus9Fukr+QAIHjTWxXXX53n1r1OaKR/rcsN84yTFG71UjL60hV/99YE6GLtXvcOCaOgkrkK6N2xutvVYUyTB6U9n2UW8GruiWzB18gvC0TBYg3Sn/311U1gcmxCE0OUdD07grRTaTHnbC3btpaAEWnw8CAZeBQDbulEIFcmtoBeXN9rtx5Q+u6MRzQxGAh9p2ZbItdlm9Bg7PkCTWbPR+soNcw599CGTVLXipfnmkAExT+oo08MIp4qKj4IohHQhMRaUGr0z3aeubrRiVZA85KKB2SzQdYYY6vRDeisduCszlZ90odygvJ9DVcH9YtFY75nj8Vbdpgldzh7IjIgO1WaAizxy9IZZysh9NSRXdfzwixtwJ8p9qskwrg0qapa7t+tOk4GqFJFhcHhjDorFACsDSfayoJ50kbPCwMD3ZsXNFnPtFtQjOLgj8tXVz1EovrMIuj6oFXu6wFK9He5CUa8S9fgmR+GWOKE+GgGgWziC8CSZO3xr9KtwIUYT4Jw7zdX1ODDmJW39Hm6Mi+8AQ="
+ file: tomlcheck-$TARGET
+ on:
+ tags: true
+ provider: releases
+ skip_cleanup: true
+
+branches:
+ only:
+ - master
+ - /\d+\.\d+\.\d+\.\d+.*$/
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5bbb9c3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,11 @@
+Copyright Vanessa McHale (c) 2017
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. 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.
+
+3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..42fe415
--- /dev/null
+++ b/README.md
@@ -0,0 +1,24 @@
+# tomlcheck
+
+[![Build Status](https://travis-ci.org/vmchale/tomlcheck.svg?branch=master)](https://travis-ci.org/vmchale/tomlcheck)
+
+`tomlcheck` is a command-line wrapper around the `htoml` library which can be
+used as a syntax checker for TOML.
+
+You can find a vim plugin [here](https://github.com/vmchale/tomlcheck-vim).
+
+## Installation
+
+### Binaries
+
+Head over to the [release page](link goes here) to see if your platform has
+binaries. Simply put it somewhere on your path.
+
+### Cabal
+
+Install [GHC & cabal](https://www.haskell.org/downloads#minimal), then
+
+```bash
+ $ cabal update
+ $ cabal install tomlcheck
+```
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
index 0000000..9a994af
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/app/Main.hs b/app/Main.hs
new file mode 100644
index 0000000..6ca9623
--- /dev/null
+++ b/app/Main.hs
@@ -0,0 +1,6 @@
+module Main where
+
+import Lib (exec)
+
+main :: IO ()
+main = exec
diff --git a/cabal.project.local b/cabal.project.local
new file mode 100644
index 0000000..9d9cad7
--- /dev/null
+++ b/cabal.project.local
@@ -0,0 +1,2 @@
+optimization: 1
+constraints: tomlcheck +development
diff --git a/src/Lib.hs b/src/Lib.hs
new file mode 100644
index 0000000..0275dcd
--- /dev/null
+++ b/src/Lib.hs
@@ -0,0 +1,32 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE TypeOperators #-}
+
+module Lib
+ ( exec
+ ) where
+
+import qualified Data.Text.IO as TIO
+import GHC.Generics (Generic)
+import Options.Generic
+import Text.Megaparsec (parseErrorPretty)
+import Text.Toml (parseTomlDoc)
+
+newtype Program = Program { file :: FilePath <?> "Path to file to be checked." }
+ deriving (Generic)
+
+programModifiers :: Modifiers
+programModifiers = defaultModifiers { shortNameModifier = firstLetter }
+
+instance ParseRecord Program where
+ parseRecord = parseRecordWithModifiers programModifiers
+
+exec :: IO ()
+exec = do
+ x <- getRecord "Command-line wrapper around htoml"
+ let path = unHelpful $ file x
+ contents <- TIO.readFile path
+ case parseTomlDoc path contents of
+ Right{} -> pure ()
+ Left e -> putStrLn $ parseErrorPretty e
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000..442f5be
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,9 @@
+resolver: lts-9.6
+packages:
+ - './'
+extra-deps:
+ - megaparsec-6.2.0
+ - htoml-megaparsec-1.0.1.0
+ - composition-prelude-0.1.1.0
+flags: {}
+extra-package-dbs: []
diff --git a/tomlcheck.cabal b/tomlcheck.cabal
new file mode 100644
index 0000000..b85f309
--- /dev/null
+++ b/tomlcheck.cabal
@@ -0,0 +1,57 @@
+name: tomlcheck
+version: 0.1.0.0
+synopsis: Command-line tool to check syntax of TOML files
+description: This is a command-line wrapper around htoml-megaparsec.
+ It is intended to be used as a syntax checker that can be
+ called by your text editor.
+homepage: https://github.com/vmchale/tomlcheck#readme
+license: BSD3
+license-file: LICENSE
+author: Vanessa McHale
+maintainer: vanessa.mchale@reconfigure.io
+copyright: Copyright: (c) 2017 Vanessa McHale
+category: Toml, Data
+build-type: Simple
+extra-source-files: cabal.project.local
+ , stack.yaml
+cabal-version: >=1.18
+Data-files: .travis.yml
+Extra-doc-files: README.md
+
+Flag development {
+ Description: Enable `-Werror`
+ manual: True
+ default: False
+}
+
+library
+ hs-source-dirs: src
+ exposed-modules: Lib
+ build-depends: base >= 4.8 && < 5
+ , htoml-megaparsec >= 1.0.1.0
+ , optparse-generic
+ , megaparsec >= 6.0
+ , text
+ default-language: Haskell2010
+ if flag(development) && impl(ghc >= 8.0)
+ ghc-options: -Werror
+ if impl(ghc >= 8.0)
+ ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat
+ ghc-options: -Wall
+
+executable tomlcheck
+ hs-source-dirs: app
+ main-is: Main.hs
+ -- ghc-options: -threaded -rtsopts -with-rtsopts=-N
+ build-depends: base
+ , tomlcheck
+ default-language: Haskell2010
+ if flag(development)
+ ghc-options: -Werror
+ if impl(ghc >= 8.0)
+ ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat
+ ghc-options: -Wall
+
+source-repository head
+ type: git
+ location: https://github.com/vmchale/tomlcheck