expire, trust et al, dead, describe: Support --json and --json-error-messages
For expire, the normal output is unchanged, but the --json output includes the uuid in machine parseable form. Which could be very useful for this somewhat obscure command. That needed ActionItemUUID to be implemented, which seemed like a lot of work, but then --- I had been going to skip implementing them for trust, untrust, dead, semitrust, and describe, but putting the uuid in the json is useful information, it tells what uuid git-annex picked given the input. It was not hard to support these once ActionItemUUID was implemented. Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
parent
1a9af823bc
commit
365dbc89dc
18 changed files with 154 additions and 61 deletions
|
@ -15,8 +15,9 @@ import Remote (keyLocations)
|
|||
import Git.Types
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "dead" SectionSetup "hide a lost repository or key"
|
||||
(paramRepeating paramRepository) (seek <$$> optParser)
|
||||
cmd = withAnnexOptions [jsonOptions] $
|
||||
command "dead" SectionSetup "hide a lost repository or key"
|
||||
(paramRepeating paramRepository) (seek <$$> optParser)
|
||||
|
||||
data DeadOptions = DeadRemotes [RemoteName] | DeadKeys [Key]
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ seek = withWords (commandAction . start)
|
|||
start :: [String] -> CommandStart
|
||||
start (name:description) | not (null description) = do
|
||||
u <- Remote.nameToUUID name
|
||||
let ai = ActionItemUUID u (UnquotedString name)
|
||||
starting "describe" ai si $
|
||||
perform u $ unwords description
|
||||
where
|
||||
ai = ActionItemOther (Just (UnquotedString name))
|
||||
si = SeekInput [name]
|
||||
start _ = giveup "Specify a repository and a description."
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ import Data.Time.Clock.POSIX
|
|||
import qualified Data.Map as M
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "expire" SectionMaintenance
|
||||
"expire inactive repositories"
|
||||
paramExpire (seek <$$> optParser)
|
||||
cmd = withAnnexOptions [jsonOptions] $
|
||||
command "expire" SectionMaintenance
|
||||
"expire inactive repositories"
|
||||
paramExpire (seek <$$> optParser)
|
||||
|
||||
paramExpire :: String
|
||||
paramExpire = (paramRepeating $ paramOptional paramRemote ++ ":" ++ paramTime)
|
||||
|
@ -79,7 +80,7 @@ start (Expire expire) noact actlog descs u =
|
|||
return $ "last active: " ++ fromDuration d ++ " ago"
|
||||
_ -> return "no activity"
|
||||
desc = fromUUID u ++ " " ++ fromUUIDDesc (fromMaybe mempty (M.lookup u descs))
|
||||
ai = ActionItemOther (Just (UnquotedString desc))
|
||||
ai = ActionItemUUID u (UnquotedString desc)
|
||||
si = SeekInput []
|
||||
notexpired ent = case ent of
|
||||
Unknown -> False
|
||||
|
|
|
@ -12,9 +12,10 @@ import Types.TrustLevel
|
|||
import Command.Trust (trustCommand)
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "semitrust" SectionSetup
|
||||
"return repository to default trust level"
|
||||
(paramRepeating paramRepository) (withParams seek)
|
||||
cmd = withAnnexOptions [jsonOptions] $
|
||||
command "semitrust" SectionSetup
|
||||
"return repository to default trust level"
|
||||
(paramRepeating paramRepository) (withParams seek)
|
||||
|
||||
seek :: CmdParams -> CommandSeek
|
||||
seek = trustCommand "semitrust" SemiTrusted
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2023 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -17,8 +17,9 @@ import Logs.Group
|
|||
import qualified Data.Set as S
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "trust" SectionSetup "trust a repository"
|
||||
(paramRepeating paramRepository) (withParams seek)
|
||||
cmd = withAnnexOptions [jsonOptions] $
|
||||
command "trust" SectionSetup "trust a repository"
|
||||
(paramRepeating paramRepository) (withParams seek)
|
||||
|
||||
seek :: CmdParams -> CommandSeek
|
||||
seek = trustCommand "trust" Trusted
|
||||
|
@ -30,7 +31,7 @@ trustCommand c level ps = withStrings (commandAction . start) ps
|
|||
start name = do
|
||||
u <- Remote.nameToUUID name
|
||||
let si = SeekInput [name]
|
||||
starting c (ActionItemOther (Just (UnquotedString name))) si (perform name u)
|
||||
starting c (ActionItemUUID u (UnquotedString name)) si (perform name u)
|
||||
perform name uuid = do
|
||||
when (level >= Trusted) $
|
||||
unlessM (Annex.getRead Annex.force) $
|
||||
|
|
|
@ -12,8 +12,9 @@ import Types.TrustLevel
|
|||
import Command.Trust (trustCommand)
|
||||
|
||||
cmd :: Command
|
||||
cmd = command "untrust" SectionSetup "do not trust a repository"
|
||||
(paramRepeating paramRepository) (withParams seek)
|
||||
cmd = withAnnexOptions [jsonOptions] $
|
||||
command "untrust" SectionSetup "do not trust a repository"
|
||||
(paramRepeating paramRepository) (withParams seek)
|
||||
|
||||
seek :: CmdParams -> CommandSeek
|
||||
seek = trustCommand "untrust" UnTrusted
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue