factor out maybeAddJSONField

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2023-05-08 16:03:34 -04:00
parent 3d8f93dc0a
commit a5d0c85ae1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 22 additions and 18 deletions

View file

@ -18,8 +18,6 @@ import Utility.Metered
import Annex.WorkTree
import qualified Git
import qualified Annex
import Utility.Aeson
import Messages.JSON (AddJSONActionItemField(..))
cmd :: Command
cmd = withAnnexOptions [backendOption, jsonOptions] $
@ -98,9 +96,7 @@ notAnnexed src a =
perform :: RawFilePath -> Key -> CommandPerform
perform src key = do
case toJSON' (AddJSONActionItemField "key" (serializeKey key)) of
Object o -> maybeShowJSON $ AesonObject o
_ -> noop
maybeAddJSONField "key" (serializeKey key)
ifM move
( next $ cleanup key
, giveup "failed"