yaml 0.8.7.2 → 0.8.8
raw patch · 2 files changed
+40/−2 lines, 2 filesdep ~aesonnew-component:exe:json2yaml
Dependency ranges changed: aeson
Files
- exe/json2yaml.hs +25/−0
- yaml.cabal +15/−2
+ exe/json2yaml.hs view
@@ -0,0 +1,25 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FlexibleInstances #-}+import System.Environment (getArgs)+import qualified Data.Aeson as J+import qualified Data.Yaml as Y+import Control.Monad (when)+import qualified Data.ByteString as S+import qualified Data.ByteString.Lazy as L+import Control.Applicative ((<$>))++main :: IO ()+main = do+ args <- getArgs+ when (length args > 2) $ error "Usage: json2yaml [in] [out]"+ let (input:output:_) = args ++ repeat "-"+ mval <- J.decode <$>+ case input of+ "-" -> L.getContents+ _ -> L.readFile input+ case mval of+ Nothing -> error "Invalid input JSON"+ Just val -> do+ case output of+ "-" -> S.putStr $ Y.encode (val :: Y.Value)+ _ -> Y.encodeFile output val
yaml.cabal view
@@ -1,5 +1,5 @@ name: yaml-version: 0.8.7.2+version: 0.8.8 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov @@ -30,7 +30,7 @@ test/json.yaml flag no-exe- description: don't install the yaml2json executable+ description: don't install the yaml2json or json2yaml executables default: False flag system-libyaml@@ -79,6 +79,19 @@ hs-source-dirs: exe main-is: yaml2json.hs+ build-depends: base >= 4 && < 5+ , yaml+ , bytestring >= 0.9.1.4+ , aeson >= 0.5++executable json2yaml+ if flag(no-exe)+ Buildable: False+ else+ Buildable: True++ hs-source-dirs: exe+ main-is: json2yaml.hs build-depends: base >= 4 && < 5 , yaml , bytestring >= 0.9.1.4