packages feed

bunz 0.0.2 → 0.0.3

raw patch · 4 files changed

+41/−14 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Beautifier: beautify :: String -> String
+ Beautifier: beautify :: Text -> Text

Files

README.md view
@@ -1,6 +1,29 @@ # Bunz JSON beautifier cli tool written in Haskell +## Usage+```+λ   bunz [master] + bunz "{\"foo\":\"bar\"}"+{+  "foo": "bar"+}++λ   bunz [master] + cat test.json | bunz+{+  "name": "sendy",+  "popular": false,+  "friend": {+    "name": "\"The rock\n\n\t?",+    "points": [+      1,+      2,+      34,+      5+    ]+  }+}+```+ ## Installation Bunz requires [Haskell stack tool](https://github.com/commercialhaskell/stack) to install 
app/Main.hs view
@@ -3,10 +3,12 @@ module Main where  import qualified Beautifier             as B+import qualified Data.Text.Lazy         as T+import qualified Data.Text.Lazy.IO      as TextIO import           System.Console.CmdArgs ((&=)) import qualified System.Console.CmdArgs as CA-import qualified System.Posix.IO        as IO-import qualified System.Posix.Terminal  as T+import           System.Posix.IO        (stdInput)+import           System.Posix.Terminal  (queryTerminal)  data Args = Args { jsonString :: String }   deriving (Show, CA.Data, CA.Typeable)@@ -16,16 +18,16 @@     &= CA.summary "JSON beautifier tool version 0.0.1"  main :: IO ()-main = T.queryTerminal IO.stdInput >>= run+main = queryTerminal stdInput >>= run -printBeautified :: String -> IO ()-printBeautified = putStrLn . B.beautify+printBeautified :: T.Text -> IO ()+printBeautified = TextIO.putStr . B.beautify  runFromStdInput :: IO ()-runFromStdInput = getContents >>= printBeautified+runFromStdInput = TextIO.getContents >>= printBeautified  runFromArgs :: Args -> IO ()-runFromArgs (Args { jsonString = str }) = printBeautified str+runFromArgs (Args { jsonString = str }) = printBeautified $ T.pack str  run :: Bool -> IO () run False = runFromStdInput
bunz.cabal view
@@ -1,5 +1,5 @@ name:                bunz-version:             0.0.2+version:             0.0.3 synopsis:            CLI tool to beautify JSON string. description:         CLI tool to beautify JSON string. homepage:            https://github.com/sendyhalim/bunz@@ -27,6 +27,7 @@   ghc-options:         -threaded -rtsopts -with-rtsopts=-N   build-depends:       base                      , bunz+                     , text == 1.2.2.2                      , unix == 2.7.2.1                      , cmdargs >= 0.10.18   default-language:    Haskell2010
src/Beautifier.hs view
@@ -8,15 +8,16 @@   , splitAtHead   ) where -import           Data.Monoid ((<>))-import qualified Data.String as S-import qualified Data.Text   as T+import           Data.Int       (Int64)+import           Data.Monoid    ((<>))+import qualified Data.String    as S+import qualified Data.Text.Lazy as T  -- Doctest setup -- $setup -- >>> :set -XOverloadedStrings -type IndentationLevel = Int+type IndentationLevel = Int64  indentation :: T.Text indentation = "  "@@ -117,5 +118,5 @@       <> beautifyText (i - 1) (trimmedTail str)  -beautify :: String -> String-beautify = T.unpack . beautifyText 0 . T.pack+beautify :: T.Text -> T.Text+beautify = beautifyText 0