yaml 0.8.24 → 0.8.25
raw patch · 3 files changed
+13/−4 lines, 3 files
Files
- ChangeLog.md +6/−0
- exe/yaml2json.hs +6/−3
- yaml.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,9 @@+## 0.8.25++* Tweaks to the executable `yaml2json` [#119](https://github.com/snoyberg/yaml/pull/119): + - Add command-line option `-h` and `--help` to show help message+ - Error messages are now written to `stderr` instead of `stdout`+ ## 0.8.24 * New encodePretty option `setConfDropNull` to drop null values from objects [#116](https://github.com/snoyberg/yaml/issues/116)
exe/yaml2json.hs view
@@ -5,16 +5,17 @@ import Data.ByteString.Lazy (putStr) import System.Environment (getArgs) import System.Exit+import System.IO (stderr, hPutStrLn) import Data.Yaml (decodeFileEither, decodeEither') helpMessage :: IO ()-helpMessage = putStrLn "yaml2json FILE\n use - as FILE to indicate stdin" >> exitFailure+helpMessage = putStrLn "Usage: yaml2json FILE\n\nuse '-' as FILE to indicate stdin" >> exitFailure showJSON :: Show a => Either a Value -> IO b showJSON ejson = case ejson of- Left err -> print err >> exitFailure+ Left err -> hPutStrLn stderr (show err) >> exitFailure Right res -> putStr (encode (res :: Value)) >> exitSuccess main :: IO ()@@ -22,7 +23,9 @@ args <- getArgs case args of -- strict getContents will read in all of stdin at once+ (["-h"]) -> helpMessage+ (["--help"]) -> helpMessage (["-"]) -> getContents >>= showJSON . decodeEither' ([f]) -> decodeFileEither f >>= showJSON _ -> helpMessage- +
yaml.cabal view
@@ -1,5 +1,5 @@ name: yaml-version: 0.8.24+version: 0.8.25 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov