remove --backend from global options

--backend is no longer a global option, and is only accepted by commands
that actually need it.

Three commands that used to support backend but don't any longer are
watch, webapp, and assistant. It would be possible to make them support it,
but I doubt anyone used the option with these. And in the case of webapp
and assistant, the option was handled inconsistently, only taking affect
when the command is run with an existing git-annex repo, not when it
creates a new one.

Also, renamed GlobalOption etc to AnnexOption. Because there are many
options of this type that are not actually global (any more) and get
added to commands that need them.

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2022-06-29 13:28:08 -04:00
parent 3eecf2033a
commit b223988e22
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
49 changed files with 209 additions and 196 deletions

View file

@ -34,12 +34,13 @@ import System.PosixCompat.Files
cmd :: Command
cmd = notBareRepo $
withGlobalOptions opts $
withAnnexOptions opts $
command "add" SectionCommon "add files to annex"
paramPaths (seek <$$> optParser)
where
opts =
[ jobsOption
[ backendOption
, jobsOption
, jsonOptions
, jsonProgressOption
, fileMatchingOptions LimitDiskFiles

View file

@ -37,7 +37,7 @@ import Network.URI
import qualified System.FilePath.ByteString as P
cmd :: Command
cmd = notBareRepo $ withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption] $
cmd = notBareRepo $ withAnnexOptions [jobsOption, jsonOptions, jsonProgressOption] $
command "addurl" SectionCommon "add urls to annex"
(paramRepeating paramUrl) (seek <$$> optParser)

View file

@ -14,10 +14,11 @@ import Utility.Metered
cmd :: Command
cmd = noCommit $ noMessages $ dontCheck repoExists $
command "calckey" SectionPlumbing
"calulate key for a file"
(paramRepeating paramFile)
(batchable run (pure ()))
withAnnexOptions [backendOption] $
command "calckey" SectionPlumbing
"calulate key for a file"
(paramRepeating paramFile)
(batchable run (pure ()))
run :: () -> SeekInput -> String -> Annex Bool
run _ _ file = tryNonAsync (genKey ks nullMeterUpdate Nothing) >>= \case

View file

@ -14,7 +14,7 @@ import Annex.Wanted
import Annex.NumCopies
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
cmd = withAnnexOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
command "copy" SectionCommon
"copy content of files to/from another repository"
paramPaths (seek <--< optParser)

View file

@ -22,7 +22,7 @@ import Annex.Wanted
import Annex.Notification
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, annexedMatchingOptions] $
cmd = withAnnexOptions [jobsOption, jsonOptions, annexedMatchingOptions] $
command "drop" SectionCommon
"remove content of files from repository"
paramPaths (seek <$$> optParser)

View file

@ -13,7 +13,7 @@ import Logs.Location
import Annex.Content
cmd :: Command
cmd = noCommit $ withGlobalOptions [jsonOptions] $
cmd = noCommit $ withAnnexOptions [jsonOptions] $
command "dropkey" SectionPlumbing
"drops annexed content for specified keys"
(paramRepeating paramKey)

View file

@ -20,7 +20,7 @@ import qualified Data.ByteString as B
cmd :: Command
cmd = noCommit $ noMessages $ dontCheck repoExists $
withGlobalOptions [jsonOptions] $
withAnnexOptions [jsonOptions] $
command "examinekey" SectionPlumbing
"prints information from a key"
(paramRepeating paramKey)

View file

@ -44,7 +44,7 @@ import qualified Data.Map as M
import Control.Concurrent
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption] $
cmd = withAnnexOptions [jobsOption, jsonOptions, jsonProgressOption] $
command "export" SectionCommon
"export a tree of files to a special remote"
paramTreeish (seek <$$> optParser)

View file

@ -36,7 +36,7 @@ import Data.ByteString.Builder
import qualified System.FilePath.ByteString as P
cmd :: Command
cmd = noMessages $ withGlobalOptions [annexedMatchingOptions] $
cmd = noMessages $ withAnnexOptions [annexedMatchingOptions] $
command "filter-branch" SectionMaintenance
"filter information from the git-annex branch"
paramPaths (seek <$$> optParser)

View file

@ -21,12 +21,12 @@ import qualified Utility.Format
import Utility.DataUnits
cmd :: Command
cmd = notBareRepo $ withGlobalOptions [annexedMatchingOptions] $ mkCommand $
cmd = notBareRepo $ withAnnexOptions [annexedMatchingOptions] $ mkCommand $
command "find" SectionQuery "lists available files"
paramPaths (seek <$$> optParser)
mkCommand :: Command -> Command
mkCommand = noCommit . noMessages . withGlobalOptions [jsonOptions]
mkCommand = noCommit . noMessages . withAnnexOptions [jsonOptions]
data FindOptions = FindOptions
{ findThese :: CmdParams

View file

@ -12,7 +12,7 @@ import qualified Command.Find as Find
import qualified Git
cmd :: Command
cmd = withGlobalOptions [annexedMatchingOptions] $ Find.mkCommand $
cmd = withAnnexOptions [annexedMatchingOptions] $ Find.mkCommand $
command "findref" SectionPlumbing
"lists files in a git ref (deprecated)"
paramRef (seek <$$> Find.optParser)

View file

@ -25,7 +25,7 @@ import qualified System.Posix.Files as Posix
#endif
cmd :: Command
cmd = noCommit $ withGlobalOptions [annexedMatchingOptions] $
cmd = noCommit $ withAnnexOptions [annexedMatchingOptions] $
command "fix" SectionMaintenance
"fix up links to annexed content"
paramPaths (withParams seek)

View file

@ -22,7 +22,7 @@ import Git.FilePath
import Network.URI
cmd :: Command
cmd = notBareRepo $ withGlobalOptions [jsonOptions] $
cmd = notBareRepo $ withAnnexOptions [jsonOptions] $
command "fromkey" SectionPlumbing "adds a file using a specific key"
(paramRepeating (paramPair paramKey paramPath))
(seek <$$> optParser)

View file

@ -51,7 +51,7 @@ import Data.Either
import qualified System.FilePath.ByteString as P
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, annexedMatchingOptions] $
cmd = withAnnexOptions [jobsOption, jsonOptions, annexedMatchingOptions] $
command "fsck" SectionMaintenance
"find and fix problems"
paramPaths (seek <$$> optParser)

View file

@ -15,7 +15,7 @@ import Annex.Wanted
import qualified Command.Move
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
cmd = withAnnexOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
command "get" SectionCommon
"make content of annexed files available"
paramPaths (seek <$$> optParser)

View file

@ -40,14 +40,15 @@ import Control.Concurrent.STM
cmd :: Command
cmd = notBareRepo $
withGlobalOptions opts $
withAnnexOptions opts $
command "import" SectionCommon
"add a tree of files to the repository"
(paramPaths ++ "|BRANCH")
(seek <$$> optParser)
where
opts =
[ jobsOption
[ backendOption
, jobsOption
, jsonOptions
, jsonProgressOption
-- These options are only used when importing from a

View file

@ -97,7 +97,7 @@ emptyStatInfo = StatInfo Nothing Nothing M.empty Nothing
type StatState = StateT StatInfo Annex
cmd :: Command
cmd = noCommit $ withGlobalOptions [jsonOptions, annexedMatchingOptions] $
cmd = noCommit $ withAnnexOptions [jsonOptions, annexedMatchingOptions] $
command "info" SectionQuery
"information about an item or the repository"
(paramRepeating paramItem) (seek <$$> optParser)

View file

@ -22,7 +22,7 @@ import Git.Types (RemoteName)
import Utility.Tuple
cmd :: Command
cmd = noCommit $ withGlobalOptions [annexedMatchingOptions] $
cmd = noCommit $ withAnnexOptions [annexedMatchingOptions] $
command "list" SectionQuery
"show which remotes contain files"
paramPaths (seek <$$> optParser)

View file

@ -22,7 +22,7 @@ import Git.FilePath
import qualified Utility.RawFilePath as R
cmd :: Command
cmd = withGlobalOptions [jsonOptions, annexedMatchingOptions] $
cmd = withAnnexOptions [jsonOptions, annexedMatchingOptions] $
command "lock" SectionCommon
"undo unlock command"
paramPaths (withParams seek)

View file

@ -36,7 +36,7 @@ data LogChange = Added | Removed
type Outputter = LogChange -> POSIXTime -> [UUID] -> Annex ()
cmd :: Command
cmd = withGlobalOptions [annexedMatchingOptions] $
cmd = withAnnexOptions [annexedMatchingOptions] $
command "log" SectionQuery "shows location log"
paramPaths (seek <$$> optParser)

View file

@ -25,7 +25,7 @@ import qualified Data.ByteString.Lazy.UTF8 as BU
import Control.Concurrent
cmd :: Command
cmd = withGlobalOptions [jsonOptions, annexedMatchingOptions] $
cmd = withAnnexOptions [jsonOptions, annexedMatchingOptions] $
command "metadata" SectionMetaData
"sets or gets metadata of a file"
paramPaths (seek <$$> optParser)

View file

@ -20,7 +20,7 @@ import Logs.Web
import Utility.Metered
cmd :: Command
cmd = withGlobalOptions [annexedMatchingOptions] $
cmd = withAnnexOptions [backendOption, annexedMatchingOptions] $
command "migrate" SectionUtility
"switch data to different backend"
paramPaths (seek <$$> optParser)

View file

@ -17,7 +17,7 @@ import Annex.NumCopies
import Types.Transfer
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
cmd = withAnnexOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
command "mirror" SectionCommon
"mirror content of files to/from another repository"
paramPaths (seek <--< optParser)

View file

@ -25,7 +25,7 @@ import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy as L
cmd :: Command
cmd = withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
cmd = withAnnexOptions [jobsOption, jsonOptions, jsonProgressOption, annexedMatchingOptions] $
command "move" SectionCommon
"move content of files to/from another repository"
paramPaths (seek <--< optParser)

View file

@ -13,7 +13,7 @@ import Command.FromKey (keyOpt, keyOpt')
import qualified Remote
cmd :: Command
cmd = withGlobalOptions [jsonOptions] $ command "registerurl"
cmd = withAnnexOptions [jsonOptions] $ command "registerurl"
SectionPlumbing "registers an url for a key"
(paramPair paramKey paramUrl)
(seek <$$> optParser)

View file

@ -16,10 +16,11 @@ import Utility.Metered
import qualified Git
cmd :: Command
cmd = command "reinject" SectionUtility
"inject content of file back into annex"
(paramRepeating (paramPair "SRC" "DEST"))
(seek <$$> optParser)
cmd = withAnnexOptions [backendOption] $
command "reinject" SectionUtility
"inject content of file back into annex"
(paramRepeating (paramPair "SRC" "DEST"))
(seek <$$> optParser)
data ReinjectOptions = ReinjectOptions
{ params :: CmdParams

View file

@ -13,7 +13,7 @@ import Git.FilePath
cmd :: Command
cmd = notBareRepo $ noCommit $ noMessages $
withGlobalOptions [jsonOptions] $
withAnnexOptions [jsonOptions] $
command "status" SectionCommon
"show the working tree status"
paramPaths (seek <$$> optParser)

View file

@ -83,7 +83,7 @@ import qualified Data.ByteString as S
import Data.Char
cmd :: Command
cmd = withGlobalOptions [jobsOption] $
cmd = withAnnexOptions [jobsOption, backendOption] $
command "sync" SectionCommon
"synchronize local repository with remotes"
(paramRepeating paramRemote) (seek <--< optParser)

View file

@ -20,7 +20,7 @@ import Git.FilePath
import qualified Utility.RawFilePath as R
cmd :: Command
cmd = withGlobalOptions [annexedMatchingOptions] $
cmd = withAnnexOptions [annexedMatchingOptions] $
command "unannex" SectionUtility
"undo accidental add command"
paramPaths (withParams seek)

View file

@ -25,7 +25,7 @@ editcmd :: Command
editcmd = mkcmd "edit" "same as unlock"
mkcmd :: String -> String -> Command
mkcmd n d = withGlobalOptions [jsonOptions, annexedMatchingOptions] $
mkcmd n d = withAnnexOptions [jsonOptions, annexedMatchingOptions] $
command n SectionCommon d paramPaths (withParams seek)
seek :: CmdParams -> CommandSeek

View file

@ -14,7 +14,7 @@ import Logs.Web
import Command.RegisterUrl (seekBatch, start, optParser, RegisterUrlOptions(..))
cmd :: Command
cmd = withGlobalOptions [jsonOptions] $ command "unregisterurl"
cmd = withAnnexOptions [jsonOptions] $ command "unregisterurl"
SectionPlumbing "unregisters an url for a key"
(paramPair paramKey paramUrl)
(seek <$$> optParser)

View file

@ -24,7 +24,7 @@ import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
cmd :: Command
cmd = noCommit $ withGlobalOptions [annexedMatchingOptions] $
cmd = noCommit $ withAnnexOptions [annexedMatchingOptions] $
command "whereused" SectionQuery
"lists repositories that have file content"
paramNothing (seek <$$> optParser)

View file

@ -23,7 +23,7 @@ import qualified Data.Map as M
import qualified Data.Vector as V
cmd :: Command
cmd = noCommit $ withGlobalOptions [jsonOptions, annexedMatchingOptions] $
cmd = noCommit $ withAnnexOptions [jsonOptions, annexedMatchingOptions] $
command "whereis" SectionQuery
"lists repositories that have file content"
paramPaths (seek <$$> optParser)