summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabrielGonzalez <>2018-12-29 17:55:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-12-29 17:55:00 (GMT)
commit915f9fb4de4f71677c518db68060069b3439a8af (patch)
tree4115f98f584d88b2d1ff1bf5c4903ab5f910884f
parent0cdd7871f2f7f60e7204a04510d26b3d31bbea14 (diff)
version 1.2.61.2.6
-rw-r--r--CHANGELOG.md11
-rw-r--r--dhall-json.cabal8
-rw-r--r--dhall-to-json/Main.hs38
3 files changed, 50 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf8ba6b..85beec4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+1.2.6
+
+* Add `--version` flag
+ * See: https://github.com/dhall-lang/dhall-haskell/pull/704
+* Build against `tasty-1.2`
+ * See: https://github.com/dhall-lang/dhall-haskell/pull/731
+* Add `--compact` flag to `dhall-to-json`
+ * Eventually `--pretty` will become the default, so this flag provides a
+ way for a user to preserve the old 1-line output when that happens
+ * See: https://github.com/dhall-lang/dhall-haskell/pull/743
+
1.2.5
* Build against `dhall-1.19.0`
diff --git a/dhall-json.cabal b/dhall-json.cabal
index f3bb1d7..8d14f7c 100644
--- a/dhall-json.cabal
+++ b/dhall-json.cabal
@@ -1,5 +1,5 @@
Name: dhall-json
-Version: 1.2.5
+Version: 1.2.6
Cabal-Version: >=1.8.0.2
Build-Type: Simple
Tested-With: GHC == 7.10.2, GHC == 8.0.1
@@ -35,7 +35,7 @@ Library
Build-Depends:
base >= 4.8.0.0 && < 5 ,
aeson >= 1.0.0.0 && < 1.5 ,
- dhall >= 1.19.0 && < 1.20,
+ dhall >= 1.19.0 && < 1.21,
optparse-applicative >= 0.14.0.0 && < 0.15,
text >= 0.11.1.0 && < 1.3 ,
unordered-containers < 0.3
@@ -54,6 +54,8 @@ Executable dhall-to-json
dhall-json ,
optparse-applicative ,
text
+ Other-Modules:
+ Paths_dhall_json
GHC-Options: -Wall
Executable dhall-to-yaml
@@ -80,6 +82,6 @@ Test-Suite tasty
bytestring ,
dhall ,
dhall-json ,
- tasty < 1.2,
+ tasty < 1.3,
text ,
tasty-hunit >= 0.2
diff --git a/dhall-to-json/Main.hs b/dhall-to-json/Main.hs
index f1fda41..d58130f 100644
--- a/dhall-to-json/Main.hs
+++ b/dhall-to-json/Main.hs
@@ -4,8 +4,11 @@
module Main where
+import Control.Applicative ((<|>))
import Control.Exception (SomeException)
+import Control.Monad (when)
import Data.Monoid ((<>))
+import Data.Version (showVersion)
import Dhall.JSON (Conversion)
import Options.Applicative (Parser, ParserInfo)
@@ -19,6 +22,7 @@ import qualified Dhall
import qualified Dhall.JSON
import qualified GHC.IO.Encoding
import qualified Options.Applicative
+import qualified Paths_dhall_json as Meta
import qualified System.Exit
import qualified System.IO
@@ -26,6 +30,7 @@ data Options = Options
{ explain :: Bool
, pretty :: Bool
, omitNull :: Bool
+ , version :: Bool
, conversion :: Conversion
}
@@ -34,6 +39,7 @@ parseOptions = Options.Applicative.helper <*> do
explain <- parseExplain
pretty <- parsePretty
omitNull <- parseOmitNull
+ version <- parseVersion
conversion <- Dhall.JSON.parseConversion
return (Options {..})
where
@@ -44,10 +50,24 @@ parseOptions = Options.Applicative.helper <*> do
)
parsePretty =
- Options.Applicative.switch
- ( Options.Applicative.long "pretty"
- <> Options.Applicative.help "Pretty print generated JSON"
- )
+ prettyFlag <|> compactFlag <|> defaultBehavior
+ where
+ prettyFlag =
+ Options.Applicative.flag'
+ True
+ ( Options.Applicative.long "pretty"
+ <> Options.Applicative.help "Pretty print generated JSON"
+ )
+
+ compactFlag =
+ Options.Applicative.flag'
+ False
+ ( Options.Applicative.long "compact"
+ <> Options.Applicative.help "Render JSON on one line"
+ )
+
+ defaultBehavior =
+ pure False
parseOmitNull =
Options.Applicative.switch
@@ -55,6 +75,12 @@ parseOptions = Options.Applicative.helper <*> do
<> Options.Applicative.help "Omit record fields that are null"
)
+ parseVersion =
+ Options.Applicative.switch
+ ( Options.Applicative.long "version"
+ <> Options.Applicative.help "Display version"
+ )
+
parserInfo :: ParserInfo Options
parserInfo =
Options.Applicative.info
@@ -69,6 +95,10 @@ main = do
Options {..} <- Options.Applicative.execParser parserInfo
+ when version $ do
+ putStrLn (showVersion Meta.version)
+ System.Exit.exitSuccess
+
handle $ do
let config = Data.Aeson.Encode.Pretty.Config
{ Data.Aeson.Encode.Pretty.confIndent = Data.Aeson.Encode.Pretty.Spaces 2