unused: Support --json and --json-error-messages
Generalized AddJSONActionItemField to allow it to add several fields. Not entirely happy with that, since the names of the fields have to be carefully chosen to not conflict with other json fields. And fields added that way can't be parsed back in FromJSON, except for the "fields" field that is special cased for metadata. Still, I couldn't see another way to do it. Also, omit file:null from the json output. Which does affect other commands, eg git-annex whereis --all --json. Hopefully that won't break something that expects a null file. If it did, that could be reverted, but it would be ugly to have file:null in the unused --json Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
parent
dd90c7abda
commit
c208442292
6 changed files with 40 additions and 16 deletions
|
@ -12,7 +12,7 @@ import Annex.MetaData
|
|||
import Annex.VectorClock
|
||||
import Logs.MetaData
|
||||
import Annex.WorkTree
|
||||
import Messages.JSON (JSONActionItem(..), AddJSONActionItemFields(..))
|
||||
import Messages.JSON (JSONActionItem(..), AddJSONActionItemField(..))
|
||||
import Types.Messages
|
||||
import Utility.Aeson
|
||||
import Utility.SafeOutput
|
||||
|
@ -127,7 +127,7 @@ perform c o k = case getSet o of
|
|||
cleanup :: Key -> CommandCleanup
|
||||
cleanup k = do
|
||||
m <- getCurrentMetaData k
|
||||
case toJSON' (AddJSONActionItemFields m) of
|
||||
case toJSON' (AddJSONActionItemField "fields" m) of
|
||||
Object o -> maybeShowJSON $ AesonObject o
|
||||
_ -> noop
|
||||
showLongNote $ UnquotedString $ unlines $ concatMap showmeta $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue