find --json
This commit is contained in:
parent
7227dd8f21
commit
fdf02986cf
4 changed files with 28 additions and 10 deletions
10
Messages.hs
10
Messages.hs
|
@ -20,6 +20,7 @@ module Messages (
|
|||
warning,
|
||||
indent,
|
||||
maybeShowJSON,
|
||||
showFullJSON,
|
||||
showCustom,
|
||||
showHeader,
|
||||
showRaw,
|
||||
|
@ -90,10 +91,17 @@ warning' w = do
|
|||
indent :: String -> String
|
||||
indent = join "\n" . map (\l -> " " ++ l) . lines
|
||||
|
||||
{- Shows a JSON value only when in json mode. -}
|
||||
{- Shows a JSON fragment only when in json mode. -}
|
||||
maybeShowJSON :: JSON a => [(String, a)] -> Annex ()
|
||||
maybeShowJSON v = handle (JSON.add v) q
|
||||
|
||||
{- Shows a complete JSON value, only when in json mode. -}
|
||||
showFullJSON :: JSON a => [(String, a)] -> Annex Bool
|
||||
showFullJSON v = Annex.getState Annex.output >>= liftIO . go
|
||||
where
|
||||
go Annex.JSONOutput = JSON.complete v >> return True
|
||||
go _ = return False
|
||||
|
||||
{- Performs an action that outputs nonstandard/customized output, and
|
||||
- in JSON mode wraps its output in JSON.start and JSON.end, so it's
|
||||
- a complete JSON document.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue