Permalink
Browse files

Pretty-print user data

  • Loading branch information...
1 parent e4eb1d4 commit 3a62d7c81c931815080296df50dfeb4e22638f27 @dzhus committed Feb 19, 2012
Showing with 10 additions and 1 deletion.
  1. +2 −0 snap-auth-cli.cabal
  2. +8 −1 src/Main.hs
View
2 snap-auth-cli.cabal
@@ -19,7 +19,9 @@ executable snap-auth-cli
ghc-options: -Wall
build-depends:
+ aeson-pretty == 0.6.*,
base >= 4 && < 5,
+ bytestring == 0.9.*,
clientsession == 0.7.*,
snap >= 0.7.1 && < 0.8,
text == 0.11.*,
View
9 src/Main.hs
@@ -12,7 +12,10 @@ where
import Data.Functor
+import Data.Aeson.Encode.Pretty
+
import qualified Data.Text as T (pack)
+import qualified Data.ByteString.Lazy as LB (putStr)
import qualified Data.ByteString.UTF8 as B (fromString)
import System.Console.GetOpt
@@ -125,8 +128,12 @@ main =
case (optMode opts, optLogin opts, optPassword opts) of
(Nothing, _, _) -> ioError (userError "No operation mode selected")
(_, Nothing, _) -> ioError $ userError "No user selected"
- (Just Show', Just l, _) -> mgrOldUser amgr l (\_ u -> print u)
+
+ (Just Show', Just l, _) -> mgrOldUser amgr l
+ (\_ u -> LB.putStr $ encodePretty u)
+
(Just Delete, Just l, _) -> mgrOldUser amgr l destroy
+
(Just Create, Just l, Just p) -> mgrNewUser amgr (l, p)
>> return ()
(Just Create, _, Nothing) -> ioError $ userError "No password set"

0 comments on commit 3a62d7c

Please sign in to comment.