examinekey: Added two new format variables: objectpath and objectpointer

This commit is contained in:
Joey Hess 2020-11-12 13:02:31 -04:00
parent c5141b469a
commit 12e32d1dee
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 22 additions and 10 deletions

View file

@ -10,6 +10,7 @@ module Command.ExamineKey where
import Command
import qualified Utility.Format
import Command.Find (parseFormatOption, showFormatted, keyVars)
import Annex.Link
cmd :: Command
cmd = noCommit $ noMessages $ dontCheck repoExists $
@ -22,5 +23,10 @@ cmd = noCommit $ noMessages $ dontCheck repoExists $
run :: Maybe Utility.Format.Format -> SeekInput -> String -> Annex Bool
run format _ p = do
let k = fromMaybe (giveup "bad key") $ deserializeKey p
showFormatted format (serializeKey' k) (keyVars k)
objectpath <- calcRepo $ gitAnnexLocation k
let objectpointer = formatPointer k
showFormatted format (serializeKey' k) $
[ ("objectpath", fromRawFilePath objectpath)
, ("objectpointer", fromRawFilePath objectpointer)
] ++ keyVars k
return True