diff options
author | Joey Hess <joeyh@joeyh.name> | 2018-02-06 13:03:55 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2018-02-06 13:03:55 -0400 |
commit | 465da37961ea77a30363d2193e625c5781bd9302 (patch) | |
tree | 020054765eee8af0b03a131a16eff7c4f2c2688f /Messages.hs | |
parent | 34276bb91c9a36854d215ae50bfba2e207a6e6a4 (diff) |
Added INFO to external special remote protocol.
It's left up to the special remote to detect when git-annex is new enough
to support the message; an old git-annex will blow up.
This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Messages.hs')
-rw-r--r-- | Messages.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Messages.hs b/Messages.hs index 08a7bb719..d5dee72e2 100644 --- a/Messages.hs +++ b/Messages.hs @@ -19,6 +19,7 @@ module Messages ( showStoringStateAction, showOutput, showLongNote, + showInfo, showEndOk, showEndFail, showEndResult, @@ -123,7 +124,15 @@ showOutput = unlessM commandProgressDisabled $ outputMessage JSON.none "\n" showLongNote :: String -> Annex () -showLongNote s = outputMessage (JSON.note s) ('\n' : indent s ++ "\n") +showLongNote s = outputMessage (JSON.note s) (formatLongNote s) + +formatLongNote :: String -> String +formatLongNote s = '\n' : indent s ++ "\n" + +-- Used by external special remote, displayed same as showLongNote +-- to console, but json object containing the info is emitted immediately. +showInfo :: String -> Annex () +showInfo s = outputMessage' outputJSON (JSON.info s) (formatLongNote s) showEndOk :: Annex () showEndOk = showEndResult True @@ -165,11 +174,11 @@ indent = intercalate "\n" . map (\l -> " " ++ l) . lines {- Shows a JSON chunk only when in json mode. -} maybeShowJSON :: JSON.JSONChunk v -> Annex () -maybeShowJSON v = void $ withMessageState $ outputJSON (JSON.add v) +maybeShowJSON v = void $ withMessageState $ bufferJSON (JSON.add v) {- Shows a complete JSON value, only when in json mode. -} showFullJSON :: JSON.JSONChunk v -> Annex Bool -showFullJSON v = withMessageState $ outputJSON (JSON.complete v) +showFullJSON v = withMessageState $ bufferJSON (JSON.complete v) {- Performs an action that outputs nonstandard/customized output, and - in JSON mode wraps its output in JSON.start and JSON.end, so it's |