From bc6c152e48af37fa570b2ebf0352b1b1206eaecd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 6 Mar 2016 12:56:39 -0400 Subject: improve json when showStart' is given only a key Before, the json contained file:key; change that to key: If a file and a key are given, inclue both file: and key: --- Messages/JSON.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Messages') diff --git a/Messages/JSON.hs b/Messages/JSON.hs index be3dbbc58..fa829a76c 100644 --- a/Messages/JSON.hs +++ b/Messages/JSON.hs @@ -17,13 +17,18 @@ module Messages.JSON ( import Text.JSON import qualified Utility.JSONStream as Stream - -start :: String -> Maybe String -> IO () -start command file = - putStr $ Stream.start $ ("command", command) : filepart file +import Types.Key +import Data.Maybe + +start :: String -> Maybe FilePath -> Maybe Key -> IO () +start command file key = putStr $ Stream.start $ catMaybes + [ part "command" (Just command) + , part "file" file + , part "key" (fmap key2file key) + ] where - filepart Nothing = [] - filepart (Just f) = [("file", f)] + part _ Nothing = Nothing + part l (Just v) = Just (l, v) end :: Bool -> IO () end b = putStr $ Stream.add [("success", b)] ++ Stream.end -- cgit v1.2.3