Adjust whitespaces
This commit is contained in:
parent
4f497ae881
commit
8902c819c4
15
Main.hs
15
Main.hs
@ -24,7 +24,8 @@ data Name = Name
|
||||
parser :: ParserSpec Name
|
||||
parser = Name
|
||||
`parsedBy` reqPos "name" `Descr` "Namecoin name id"
|
||||
`andBy` optPos "http://dns.dnschain.net/" "url" `Descr` "Use custom dnschain API url"
|
||||
`andBy` optPos "http://dns.dnschain.net/" "url"
|
||||
`Descr` "Use custom dnschain API url"
|
||||
`andBy` boolFlag "local" `Descr` "Use local namecoind db"
|
||||
`andBy` boolFlag "block" `Descr` "Show blockchain data (require local connecton)"
|
||||
`andBy` boolFlag "raw" `Descr` "Print raw JSON data"
|
||||
@ -37,9 +38,9 @@ exec args@Name{..} =
|
||||
if local
|
||||
then do
|
||||
out <- readProcess "namecoind" ["name_show", name] ""
|
||||
case decode $ C.pack out of
|
||||
case decode (C.pack out) of
|
||||
Just res -> do
|
||||
putStrLn $ repr value
|
||||
putStrLn (repr value)
|
||||
when block $ putStrLn (repr extra)
|
||||
where
|
||||
value = fromJust . decode . C.pack $ res |: "value"
|
||||
@ -47,10 +48,10 @@ exec args@Name{..} =
|
||||
Nothing -> putStrLn "Error parsing data"
|
||||
else do
|
||||
req <- get (url ++ name)
|
||||
print args
|
||||
let body = req ^. responseBody
|
||||
if raw
|
||||
then print body
|
||||
else case decode body of
|
||||
Just res -> putStrLn $ repr res
|
||||
Nothing -> putStrLn "Error parsing data"
|
||||
else putStrLn $
|
||||
case decode body of
|
||||
Just res -> repr res
|
||||
Nothing -> "Error parsing data"
|
||||
|
Loading…
Reference in New Issue
Block a user