Skip to content

Commit

Permalink
Pretty-print user data
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhus committed Feb 19, 2012
1 parent e4eb1d4 commit 3a62d7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions snap-auth-cli.cabal
Expand Up @@ -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.*,
Expand Down
9 changes: 8 additions & 1 deletion src/Main.hs
Expand Up @@ -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
Expand Down Expand Up @@ -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.