Merge branch 'master' into proxy-specialremotes

This commit is contained in:
Joey Hess 2024-07-01 11:23:21 -04:00
commit 8fa4e25c1e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
13 changed files with 33 additions and 14 deletions

View file

@ -12,6 +12,8 @@ git-annex (10.20240532) UNRELEASED; urgency=medium
complaining about missing tree objects.
* Tab completion of options like --from now includes special remotes,
as well as proxied remotes and clusters.
* Tab completion of many commands like info and trust now includes
remotes.
* P2P protocol version 2.
* Fix Windows build with Win32 2.13.4+
Thanks, Oleg Tolmatcev

View file

@ -1,6 +1,6 @@
{- git-annex command-line option parsing
-
- Copyright 2010-2023 Joey Hess <id@joeyh.name>
- Copyright 2010-2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -109,9 +109,12 @@ gitAnnexCommonOptions = commonOptions ++
{- Parser that accepts all non-option params. -}
cmdParams :: CmdParamsDesc -> Parser CmdParams
cmdParams paramdesc = many $ argument str
cmdParams paramdesc = cmdParamsWithCompleter paramdesc completeFiles
cmdParamsWithCompleter :: String -> Mod ArgumentFields String -> Parser CmdParams
cmdParamsWithCompleter paramdesc completers = many $ argument str
( metavar paramdesc
<> action "file"
<> completers
)
parseAutoOption :: Parser Bool
@ -597,3 +600,7 @@ completeRemotes' g input = do
completeBackends :: HasCompleter f => Mod f a
completeBackends = completeWith $
map (decodeBS . formatKeyVariety . Backend.backendVariety) Backend.builtinList
completeFiles :: HasCompleter f => Mod f a
completeFiles = action "file"

View file

@ -40,6 +40,10 @@ command name section desc paramdesc mkparser =
withParams :: (CmdParams -> v) -> CmdParamsDesc -> Parser v
withParams mkseek paramdesc = mkseek <$> cmdParams paramdesc
withParams' :: (CmdParams -> v) -> Mod ArgumentFields String -> String -> Parser v
withParams' mkseek completers paramdesc = mkseek
<$> cmdParamsWithCompleter paramdesc completers
{- Uses the supplied option parser, which yields a deferred parse,
- and calls finishParse on the result before passing it to the
- CommandSeek constructor. -}

View file

@ -22,7 +22,7 @@ cmd = withAnnexOptions [jsonOptions] $
data DeadOptions = DeadRemotes [RemoteName] | DeadKeys [Key]
optParser :: CmdParamsDesc -> Parser DeadOptions
optParser desc = (DeadRemotes <$> cmdParams desc)
optParser desc = (DeadRemotes <$> cmdParamsWithCompleter desc completeRemotes)
<|> (DeadKeys <$> many (option (str >>= parseKey)
( long "key" <> metavar paramKey
<> help "keys whose content has been irretrievably lost"

View file

@ -14,8 +14,8 @@ import Logs.UUID
cmd :: Command
cmd = command "describe" SectionSetup
"change description of a repository"
(paramPair paramRemote paramDesc)
(withParams seek)
(paramPair paramRepository paramDesc)
(withParams' seek completeRemotes)
seek :: CmdParams -> CommandSeek
seek = withWords (commandAction . start)

View file

@ -20,7 +20,7 @@ import qualified Data.Map as M
cmd :: Command
cmd = noMessages $ command "group" SectionSetup "add a repository to a group"
(paramPair paramRemote paramDesc) (seek <$$> optParser)
(paramPair paramRepository paramDesc) (seek <$$> optParser)
data GroupOptions = GroupOptions
{ cmdparams :: CmdParams
@ -29,7 +29,7 @@ data GroupOptions = GroupOptions
optParser :: CmdParamsDesc -> Parser GroupOptions
optParser desc = GroupOptions
<$> cmdParams desc
<$> cmdParamsWithCompleter desc completeRemotes
<*> switch
( long "list"
<> help "list all currently defined groups"

View file

@ -116,7 +116,7 @@ data InfoOptions = InfoOptions
optParser :: CmdParamsDesc -> Parser InfoOptions
optParser desc = InfoOptions
<$> cmdParams desc
<$> cmdParamsWithCompleter desc (completeFiles <> completeRemotes)
<*> switch
( long "bytes"
<> help "display file sizes in bytes"

View file

@ -15,7 +15,8 @@ cmd :: Command
cmd = withAnnexOptions [jsonOptions] $
command "semitrust" SectionSetup
"return repository to default trust level"
(paramRepeating paramRepository) (withParams seek)
(paramRepeating paramRepository)
(withParams' seek completeRemotes)
seek :: CmdParams -> CommandSeek
seek = trustCommand "semitrust" SemiTrusted

View file

@ -19,7 +19,8 @@ import qualified Data.Set as S
cmd :: Command
cmd = withAnnexOptions [jsonOptions] $
command "trust" SectionSetup "trust a repository"
(paramRepeating paramRepository) (withParams seek)
(paramRepeating paramRepository)
(withParams' seek completeRemotes)
seek :: CmdParams -> CommandSeek
seek = trustCommand "trust" Trusted

View file

@ -16,7 +16,8 @@ import qualified Data.Set as S
cmd :: Command
cmd = command "ungroup" SectionSetup "remove a repository from a group"
(paramPair paramRemote paramDesc) (withParams seek)
(paramPair paramRemote paramDesc)
(withParams' seek completeRemotes)
seek :: CmdParams -> CommandSeek
seek = withWords (commandAction . start)

View file

@ -14,7 +14,8 @@ import Command.Trust (trustCommand)
cmd :: Command
cmd = withAnnexOptions [jsonOptions] $
command "untrust" SectionSetup "do not trust a repository"
(paramRepeating paramRepository) (withParams seek)
(paramRepeating paramRepository)
(withParams' seek completeRemotes)
seek :: CmdParams -> CommandSeek
seek = trustCommand "untrust" UnTrusted

View file

@ -56,6 +56,7 @@ optParser :: CmdParamsDesc -> Parser UnusedOptions
optParser _ = UnusedOptions
<$> optional (strOption
( long "from" <> short 'f' <> metavar paramRemote
<> completeRemotes
<> help "remote to check for unused content"
))
<*> optional (option (eitherReader parseRefSpec)

View file

@ -27,7 +27,8 @@ cmd'
-> (UUID -> PreferredContentExpression -> Annex ())
-> Command
cmd' name desc getter setter = noMessages $
command name SectionSetup desc pdesc (withParams seek)
command name SectionSetup desc pdesc
(withParams' seek completeRemotes)
where
pdesc = paramPair paramRemote (paramOptional paramExpression)