From b223988e22931cf2243ae14289d22ef4e70e51f2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jun 2022 13:28:08 -0400 Subject: [PATCH] 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 --- CHANGELOG | 2 + CmdLine.hs | 20 +-- CmdLine/AnnexSetter.hs | 36 ++++++ CmdLine/GitAnnex.hs | 6 +- CmdLine/GitAnnex/Options.hs | 120 ++++++++++-------- CmdLine/GitAnnexShell.hs | 20 +-- CmdLine/GlobalSetter.hs | 36 ------ CmdLine/Option.hs | 31 ++--- Command.hs | 8 +- Command/Add.hs | 5 +- Command/AddUrl.hs | 2 +- Command/CalcKey.hs | 9 +- Command/Copy.hs | 2 +- Command/Drop.hs | 2 +- Command/DropKey.hs | 2 +- Command/ExamineKey.hs | 2 +- Command/Export.hs | 2 +- Command/FilterBranch.hs | 2 +- Command/Find.hs | 4 +- Command/FindRef.hs | 2 +- Command/Fix.hs | 2 +- Command/FromKey.hs | 2 +- Command/Fsck.hs | 2 +- Command/Get.hs | 2 +- Command/Import.hs | 5 +- Command/Info.hs | 2 +- Command/List.hs | 2 +- Command/Lock.hs | 2 +- Command/Log.hs | 2 +- Command/MetaData.hs | 2 +- Command/Migrate.hs | 2 +- Command/Mirror.hs | 2 +- Command/Move.hs | 2 +- Command/RegisterUrl.hs | 2 +- Command/Reinject.hs | 9 +- Command/Status.hs | 2 +- Command/Sync.hs | 2 +- Command/Unannex.hs | 2 +- Command/Unlock.hs | 2 +- Command/UnregisterUrl.hs | 2 +- Command/WhereUsed.hs | 2 +- Command/Whereis.hs | 2 +- Types/Command.hs | 4 +- Types/DeferredParse.hs | 14 +- ...option_for_init_is_in_no_effect__63__.mdwn | 2 + doc/git-annex-common-options.mdwn | 7 - doc/git-annex-import.mdwn | 4 + doc/git-annex-sync.mdwn | 5 + git-annex.cabal | 2 +- 49 files changed, 209 insertions(+), 196 deletions(-) create mode 100644 CmdLine/AnnexSetter.hs delete mode 100644 CmdLine/GlobalSetter.hs diff --git a/CHANGELOG b/CHANGELOG index 959e2a03f2..6810b10036 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ git-annex (10.20220625) UNRELEASED; urgency=medium * Improve handling of parallelization with -J when copying content from/to a git remote that is a local path. * stack.yaml: Updated to lts-19.13 + * --backend is no longer a global option, and is only accepted by + commands that actually need it. -- Joey Hess Tue, 28 Jun 2022 14:49:17 -0400 diff --git a/CmdLine.hs b/CmdLine.hs index 1cb7953660..0b553b9b2f 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -53,14 +53,14 @@ dispatch' subcommandname args fuzzy cmds allargs allcmds fields getgitrepo progn where go (Right g) = do g' <- Git.Config.read g - (cmd, seek, globalsetter) <- parsewith False cmdparser + (cmd, seek, annexsetter) <- parsewith False cmdparser (\a -> a (Just g')) O.handleParseResult - state <- applyAnnexReadSetter globalsetter <$> Annex.new g' + state <- applyAnnexReadSetter annexsetter <$> Annex.new g' Annex.eval state $ do checkEnvironment forM_ fields $ uncurry Annex.setField - prepRunCommand cmd globalsetter + prepRunCommand cmd annexsetter startup performCommandAction True cmd seek $ shutdown $ cmdnocommit cmd @@ -101,7 +101,7 @@ dispatch' subcommandname args fuzzy cmds allargs allcmds fields getgitrepo progn Just n -> n:args {- Parses command line, selecting one of the commands from the list. -} -parseCmd :: String -> String -> CmdParams -> [Command] -> (Command -> O.Parser v) -> O.ParserResult (Command, v, GlobalSetter) +parseCmd :: String -> String -> CmdParams -> [Command] -> (Command -> O.Parser v) -> O.ParserResult (Command, v, AnnexSetter) parseCmd progname progdesc allargs allcmds getparser = O.execParserPure (O.prefs O.idm) pinfo allargs where @@ -114,7 +114,7 @@ parseCmd progname progdesc allargs allcmds getparser = mkparser c = (,,) <$> pure c <*> getparser c - <*> parserGlobalOptions (cmdglobaloptions c) + <*> parserAnnexOptions (cmdannexoptions c) synopsis n d = n ++ " - " ++ d intro = mconcat $ concatMap (\l -> [H.text l, H.line]) (synopsis progname progdesc : commandList allcmds) @@ -141,14 +141,14 @@ subCmdName argv = (name, args) | "-" `isPrefixOf` a = findname as (a:c) | otherwise = (Just a, reverse c ++ as) --- | Note that the GlobalSetter must have already had its annexReadSetter +-- | Note that the AnnexSetter must have already had its annexReadSetter -- applied before entering the Annex monad to run this; that cannot be -- changed while running in the Annex monad. -prepRunCommand :: Command -> GlobalSetter -> Annex () -prepRunCommand cmd globalsetter = do +prepRunCommand :: Command -> AnnexSetter -> Annex () +prepRunCommand cmd annexsetter = do when (cmdnomessages cmd) $ Annex.setOutput QuietOutput - annexStateSetter globalsetter + annexStateSetter annexsetter whenM (Annex.getRead Annex.debugenabled) $ enableDebugOutput @@ -186,7 +186,7 @@ mkAddonCommand p subcommandname = Command , cmdparamdesc = "[PARAMS]" , cmdsection = SectionAddOn , cmddesc = "addon command" - , cmdglobaloptions = [] + , cmdannexoptions = [] , cmdinfomod = O.forwardOptions , cmdparser = parse , cmdnorepo = Just parse diff --git a/CmdLine/AnnexSetter.hs b/CmdLine/AnnexSetter.hs new file mode 100644 index 0000000000..234faf3abe --- /dev/null +++ b/CmdLine/AnnexSetter.hs @@ -0,0 +1,36 @@ +{- git-annex options that are stored in Annex + - + - Copyright 2015-2021 Joey Hess + - + - Licensed under the GNU AGPL version 3 or higher. + -} + +module CmdLine.AnnexSetter where + +import Common +import Annex +import Types.DeferredParse + +import Options.Applicative + +setAnnexState :: Annex () -> AnnexSetter +setAnnexState a = AnnexSetter a id + +setAnnexRead :: (AnnexRead -> AnnexRead) -> AnnexSetter +setAnnexRead f = AnnexSetter (return ()) f + +annexFlag :: AnnexSetter -> Mod FlagFields AnnexSetter -> AnnexOption +annexFlag = flag' + +annexOption :: (v -> AnnexSetter) -> Parser v -> AnnexOption +annexOption mk parser = mk <$> parser + +-- | Combines a bunch of AnnexOptions together into a Parser +-- that returns a AnnexSetter that can be used to set all the options that +-- are enabled. +parserAnnexOptions :: [AnnexOption] -> Parser AnnexSetter +parserAnnexOptions [] = pure mempty +parserAnnexOptions l = mconcat <$> many (foldl1 (<|>) l) + +applyAnnexReadSetter :: AnnexSetter -> (AnnexState, AnnexRead) -> (AnnexState, AnnexRead) +applyAnnexReadSetter gs (st, rd) = (st, annexReadSetter gs rd) diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs index 63889f0b44..08c2bd832b 100644 --- a/CmdLine/GitAnnex.hs +++ b/CmdLine/GitAnnex.hs @@ -130,7 +130,7 @@ import qualified Command.TestRemote import qualified Command.Benchmark cmds :: Parser TestOptions -> TestRunner -> MkBenchmarkGenerator -> [Command] -cmds testoptparser testrunner mkbenchmarkgenerator = map addGitAnnexGlobalOptions $ +cmds testoptparser testrunner mkbenchmarkgenerator = map addGitAnnexCommonOptions $ [ Command.Help.cmd , Command.Add.cmd , Command.Get.cmd @@ -245,8 +245,8 @@ cmds testoptparser testrunner mkbenchmarkgenerator = map addGitAnnexGlobalOption mkbenchmarkgenerator $ cmds testoptparser testrunner (\_ _ -> return noop) ] -addGitAnnexGlobalOptions :: Command -> Command -addGitAnnexGlobalOptions c = c { cmdglobaloptions = gitAnnexGlobalOptions ++ cmdglobaloptions c } +addGitAnnexCommonOptions :: Command -> Command +addGitAnnexCommonOptions c = c { cmdannexoptions = gitAnnexCommonOptions ++ cmdannexoptions c } run :: Parser TestOptions -> TestRunner -> MkBenchmarkGenerator -> [String] -> IO () run testoptparser testrunner mkbenchmarkgenerator args = go envmodes diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index d57305440b..96d0b1872d 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -34,66 +34,66 @@ import qualified Limit import qualified Limit.Wanted import CmdLine.Option import CmdLine.Usage -import CmdLine.GlobalSetter +import CmdLine.AnnexSetter import qualified Backend import qualified Types.Backend as Backend import Utility.HumanTime import Utility.DataUnits import Annex.Concurrent --- Global options that are accepted by all git-annex sub-commands, +-- Options that are accepted by all git-annex sub-commands, -- although not always used. -gitAnnexGlobalOptions :: [GlobalOption] -gitAnnexGlobalOptions = commonGlobalOptions ++ - [ globalOption setnumcopies $ option auto +gitAnnexCommonOptions :: [AnnexOption] +gitAnnexCommonOptions = commonOptions ++ + [ annexOption setnumcopies $ option auto ( long "numcopies" <> short 'N' <> metavar paramNumber <> help "override desired number of copies" <> hidden ) - , globalOption setmincopies $ option auto + , annexOption setmincopies $ option auto ( long "mincopies" <> short 'N' <> metavar paramNumber <> help "override minimum number of copies" <> hidden ) - , globalOption (setAnnexState . Remote.forceTrust Trusted) $ strOption + , annexOption (setAnnexState . Remote.forceTrust Trusted) $ strOption ( long "trust" <> metavar paramRemote <> help "deprecated, does not override trust setting" <> hidden <> completeRemotes ) - , globalOption (setAnnexState . Remote.forceTrust SemiTrusted) $ strOption + , annexOption (setAnnexState . Remote.forceTrust SemiTrusted) $ strOption ( long "semitrust" <> metavar paramRemote <> help "override trust setting back to default" <> hidden <> completeRemotes ) - , globalOption (setAnnexState . Remote.forceTrust UnTrusted) $ strOption + , annexOption (setAnnexState . Remote.forceTrust UnTrusted) $ strOption ( long "untrust" <> metavar paramRemote <> help "override trust setting to untrusted" <> hidden <> completeRemotes ) - , globalOption (setAnnexState . setgitconfig) $ strOption + , annexOption (setAnnexState . setgitconfig) $ strOption ( long "config" <> short 'c' <> metavar "NAME=VALUE" <> help "override git configuration setting" <> hidden ) - , globalOption setuseragent $ strOption + , annexOption setuseragent $ strOption ( long "user-agent" <> metavar paramName <> help "override default User-Agent" <> hidden ) - , globalFlag (setAnnexState $ toplevelWarning False "--trust-glacier no longer has any effect") + , annexFlag (setAnnexState $ toplevelWarning False "--trust-glacier no longer has any effect") ( long "trust-glacier" <> help "deprecated, does not trust Amazon Glacier inventory" <> hidden ) - , globalFlag (setdesktopnotify mkNotifyFinish) + , annexFlag (setdesktopnotify mkNotifyFinish) ( long "notify-finish" <> help "show desktop notification after transfer finishes" <> hidden ) - , globalFlag (setdesktopnotify mkNotifyStart) + , annexFlag (setdesktopnotify mkNotifyStart) ( long "notify-start" <> help "show desktop notification after transfer starts" <> hidden @@ -229,7 +229,7 @@ parseKey :: MonadFail m => String -> m Key parseKey = maybe (Fail.fail "invalid key") return . deserializeKey -- Options to match properties of annexed files. -annexedMatchingOptions :: [GlobalOption] +annexedMatchingOptions :: [AnnexOption] annexedMatchingOptions = concat [ keyMatchingOptions' , fileMatchingOptions' Limit.LimitAnnexFiles @@ -239,86 +239,86 @@ annexedMatchingOptions = concat ] -- Matching options that can operate on keys as well as files. -keyMatchingOptions :: [GlobalOption] +keyMatchingOptions :: [AnnexOption] keyMatchingOptions = keyMatchingOptions' ++ combiningOptions ++ timeLimitOption ++ sizeLimitOption -keyMatchingOptions' :: [GlobalOption] +keyMatchingOptions' :: [AnnexOption] keyMatchingOptions' = - [ globalOption (setAnnexState . Limit.addIn) $ strOption + [ annexOption (setAnnexState . Limit.addIn) $ strOption ( long "in" <> short 'i' <> metavar paramRemote <> help "match files present in a remote" <> hidden <> completeRemotes ) - , globalOption (setAnnexState . Limit.addCopies) $ strOption + , annexOption (setAnnexState . Limit.addCopies) $ strOption ( long "copies" <> short 'C' <> metavar paramRemote <> help "skip files with fewer copies" <> hidden ) - , globalOption (setAnnexState . Limit.addLackingCopies False) $ strOption + , annexOption (setAnnexState . Limit.addLackingCopies False) $ strOption ( long "lackingcopies" <> metavar paramNumber <> help "match files that need more copies" <> hidden ) - , globalOption (setAnnexState . Limit.addLackingCopies True) $ strOption + , annexOption (setAnnexState . Limit.addLackingCopies True) $ strOption ( long "approxlackingcopies" <> metavar paramNumber <> help "match files that need more copies (faster)" <> hidden ) - , globalOption (setAnnexState . Limit.addInBackend) $ strOption + , annexOption (setAnnexState . Limit.addInBackend) $ strOption ( long "inbackend" <> short 'B' <> metavar paramName <> help "match files using a key-value backend" <> hidden <> completeBackends ) - , globalFlag (setAnnexState Limit.addSecureHash) + , annexFlag (setAnnexState Limit.addSecureHash) ( long "securehash" <> help "match files using a cryptographically secure hash" <> hidden ) - , globalOption (setAnnexState . Limit.addInAllGroup) $ strOption + , annexOption (setAnnexState . Limit.addInAllGroup) $ strOption ( long "inallgroup" <> metavar paramGroup <> help "match files present in all remotes in a group" <> hidden ) - , globalOption (setAnnexState . Limit.addMetaData) $ strOption + , annexOption (setAnnexState . Limit.addMetaData) $ strOption ( long "metadata" <> metavar "FIELD=VALUE" <> help "match files with attached metadata" <> hidden ) - , globalFlag (setAnnexState Limit.Wanted.addWantGet) + , annexFlag (setAnnexState Limit.Wanted.addWantGet) ( long "want-get" <> help "match files the repository wants to get" <> hidden ) - , globalFlag (setAnnexState Limit.Wanted.addWantDrop) + , annexFlag (setAnnexState Limit.Wanted.addWantDrop) ( long "want-drop" <> help "match files the repository wants to drop" <> hidden ) - , globalOption (setAnnexState . Limit.addAccessedWithin) $ + , annexOption (setAnnexState . Limit.addAccessedWithin) $ option (eitherReader parseDuration) ( long "accessedwithin" <> metavar paramTime <> help "match files accessed within a time interval" <> hidden ) - , globalOption (setAnnexState . Limit.addMimeType) $ strOption + , annexOption (setAnnexState . Limit.addMimeType) $ strOption ( long "mimetype" <> metavar paramGlob <> help "match files by mime type" <> hidden ) - , globalOption (setAnnexState . Limit.addMimeEncoding) $ strOption + , annexOption (setAnnexState . Limit.addMimeEncoding) $ strOption ( long "mimeencoding" <> metavar paramGlob <> help "match files by mime encoding" <> hidden ) - , globalFlag (setAnnexState Limit.addUnlocked) + , annexFlag (setAnnexState Limit.addUnlocked) ( long "unlocked" <> help "match files that are unlocked" <> hidden ) - , globalFlag (setAnnexState Limit.addLocked) + , annexFlag (setAnnexState Limit.addLocked) ( long "locked" <> help "match files that are locked" <> hidden @@ -326,44 +326,44 @@ keyMatchingOptions' = ] -- Options to match files which may not yet be annexed. -fileMatchingOptions :: Limit.LimitBy -> [GlobalOption] +fileMatchingOptions :: Limit.LimitBy -> [AnnexOption] fileMatchingOptions lb = fileMatchingOptions' lb ++ combiningOptions ++ timeLimitOption -fileMatchingOptions' :: Limit.LimitBy -> [GlobalOption] +fileMatchingOptions' :: Limit.LimitBy -> [AnnexOption] fileMatchingOptions' lb = - [ globalOption (setAnnexState . Limit.addExclude) $ strOption + [ annexOption (setAnnexState . Limit.addExclude) $ strOption ( long "exclude" <> short 'x' <> metavar paramGlob <> help "skip files matching the glob pattern" <> hidden ) - , globalOption (setAnnexState . Limit.addInclude) $ strOption + , annexOption (setAnnexState . Limit.addInclude) $ strOption ( long "include" <> short 'I' <> metavar paramGlob <> help "limit to files matching the glob pattern" <> hidden ) - , globalOption (setAnnexState . Limit.addExcludeSameContent) $ strOption + , annexOption (setAnnexState . Limit.addExcludeSameContent) $ strOption ( long "excludesamecontent" <> short 'x' <> metavar paramGlob <> help "skip files whose content is the same as another file matching the glob pattern" <> hidden ) - , globalOption (setAnnexState . Limit.addIncludeSameContent) $ strOption + , annexOption (setAnnexState . Limit.addIncludeSameContent) $ strOption ( long "includesamecontent" <> short 'I' <> metavar paramGlob <> help "limit to files whose content is the same as another file matching the glob pattern" <> hidden ) - , globalOption (setAnnexState . Limit.addLargerThan lb) $ strOption + , annexOption (setAnnexState . Limit.addLargerThan lb) $ strOption ( long "largerthan" <> metavar paramSize <> help "match files larger than a size" <> hidden ) - , globalOption (setAnnexState . Limit.addSmallerThan lb) $ strOption + , annexOption (setAnnexState . Limit.addSmallerThan lb) $ strOption ( long "smallerthan" <> metavar paramSize <> help "match files smaller than a size" <> hidden ) ] -combiningOptions :: [GlobalOption] +combiningOptions :: [AnnexOption] combiningOptions = [ longopt "not" "negate next option" , longopt "and" "both previous and next option must match" @@ -372,19 +372,19 @@ combiningOptions = , shortopt ')' "close group of options" ] where - longopt o h = globalFlag (setAnnexState $ Limit.addSyntaxToken o) + longopt o h = annexFlag (setAnnexState $ Limit.addSyntaxToken o) ( long o <> help h <> hidden ) - shortopt o h = globalFlag (setAnnexState $ Limit.addSyntaxToken [o]) + shortopt o h = annexFlag (setAnnexState $ Limit.addSyntaxToken [o]) ( short o <> help h <> hidden ) -jsonOptions :: [GlobalOption] +jsonOptions :: [AnnexOption] jsonOptions = - [ globalFlag (setAnnexState $ Annex.setOutput (JSONOutput stdjsonoptions)) + [ annexFlag (setAnnexState $ Annex.setOutput (JSONOutput stdjsonoptions)) ( long "json" <> short 'j' <> help "enable JSON output" <> hidden ) - , globalFlag (setAnnexState $ Annex.setOutput (JSONOutput jsonerrormessagesoptions)) + , annexFlag (setAnnexState $ Annex.setOutput (JSONOutput jsonerrormessagesoptions)) ( long "json-error-messages" <> help "include error messages in JSON" <> hidden @@ -397,9 +397,9 @@ jsonOptions = } jsonerrormessagesoptions = stdjsonoptions { jsonErrorMessages = True } -jsonProgressOption :: [GlobalOption] +jsonProgressOption :: [AnnexOption] jsonProgressOption = - [ globalFlag (setAnnexState $ Annex.setOutput (JSONOutput jsonoptions)) + [ annexFlag (setAnnexState $ Annex.setOutput (JSONOutput jsonoptions)) ( long "json-progress" <> help "include progress in JSON output" <> hidden @@ -413,9 +413,9 @@ jsonProgressOption = -- Note that a command that adds this option should wrap its seek -- action in `allowConcurrentOutput`. -jobsOption :: [GlobalOption] +jobsOption :: [AnnexOption] jobsOption = - [ globalOption (setAnnexState . setConcurrency . ConcurrencyCmdLine) $ + [ annexOption (setAnnexState . setConcurrency . ConcurrencyCmdLine) $ option (maybeReader parseConcurrency) ( long "jobs" <> short 'J' <> metavar (paramNumber `paramOr` "cpus") @@ -424,9 +424,9 @@ jobsOption = ) ] -timeLimitOption :: [GlobalOption] +timeLimitOption :: [AnnexOption] timeLimitOption = - [ globalOption settimelimit $ option (eitherReader parseDuration) + [ annexOption settimelimit $ option (eitherReader parseDuration) ( long "time-limit" <> short 'T' <> metavar paramTime <> help "stop after the specified amount of time" <> hidden @@ -438,9 +438,9 @@ timeLimitOption = let cutoff = start + durationToPOSIXTime duration Annex.changeState $ \s -> s { Annex.timelimit = Just (duration, cutoff) } -sizeLimitOption :: [GlobalOption] +sizeLimitOption :: [AnnexOption] sizeLimitOption = - [ globalOption setsizelimit $ option (maybeReader (readSize dataUnits)) + [ annexOption setsizelimit $ option (maybeReader (readSize dataUnits)) ( long "size-limit" <> metavar paramSize <> help "total size of annexed files to process" <> hidden @@ -450,6 +450,18 @@ sizeLimitOption = setsizelimit n = setAnnexState $ do v <- liftIO $ newTVarIO n Annex.changeState $ \s -> s { Annex.sizelimit = Just v } + +backendOption :: [AnnexOption] +backendOption = + [ annexOption setforcebackend $ strOption + ( long "backend" <> short 'b' <> metavar paramName + <> help "specify key-value backend to use" + <> hidden + ) + ] + where + setforcebackend v = setAnnexRead $ + \rd -> rd { Annex.forcebackend = Just v } data DaemonOptions = DaemonOptions { foregroundDaemonOption :: Bool diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs index aa952d18ad..b3dd4e6774 100644 --- a/CmdLine/GitAnnexShell.hs +++ b/CmdLine/GitAnnexShell.hs @@ -11,7 +11,7 @@ import Annex.Common import qualified Git.Construct import qualified Git.Config import CmdLine -import CmdLine.GlobalSetter +import CmdLine.AnnexSetter import Command import Annex.UUID import CmdLine.GitAnnexShell.Checks @@ -37,7 +37,7 @@ cmdsMap = M.fromList $ map mk , (ServeReadWrite, allcmds) ] where - readonlycmds = map addGlobalOptions + readonlycmds = map addAnnexOptions [ Command.ConfigList.cmd , gitAnnexShellCheck Command.NotifyChanges.cmd -- p2pstdio checks the enviroment variables to @@ -46,10 +46,10 @@ cmdsMap = M.fromList $ map mk , gitAnnexShellCheck Command.InAnnex.cmd , gitAnnexShellCheck Command.SendKey.cmd ] - appendcmds = readonlycmds ++ map addGlobalOptions + appendcmds = readonlycmds ++ map addAnnexOptions [ gitAnnexShellCheck Command.RecvKey.cmd ] - allcmds = appendcmds ++ map addGlobalOptions + allcmds = appendcmds ++ map addAnnexOptions [ gitAnnexShellCheck Command.DropKey.cmd , Command.GCryptSetup.cmd ] @@ -63,16 +63,16 @@ cmdsFor = fromMaybe [] . flip M.lookup cmdsMap cmdsList :: [Command] cmdsList = nub $ concat $ M.elems cmdsMap -addGlobalOptions :: Command -> Command -addGlobalOptions c = c { cmdglobaloptions = globalOptions ++ cmdglobaloptions c } +addAnnexOptions :: Command -> Command +addAnnexOptions c = c { cmdannexoptions = commonShellOptions ++ cmdannexoptions c } -globalOptions :: [GlobalOption] -globalOptions = - globalOption (setAnnexState . checkUUID) (strOption +commonShellOptions :: [AnnexOption] +commonShellOptions = + annexOption (setAnnexState . checkUUID) (strOption ( long "uuid" <> metavar paramUUID <> help "local repository uuid" )) - : commonGlobalOptions + : commonOptions where checkUUID expected = getUUID >>= check where diff --git a/CmdLine/GlobalSetter.hs b/CmdLine/GlobalSetter.hs deleted file mode 100644 index 44073f18bb..0000000000 --- a/CmdLine/GlobalSetter.hs +++ /dev/null @@ -1,36 +0,0 @@ -{- git-annex global options - - - - Copyright 2015-2021 Joey Hess - - - - Licensed under the GNU AGPL version 3 or higher. - -} - -module CmdLine.GlobalSetter where - -import Common -import Annex -import Types.DeferredParse - -import Options.Applicative - -setAnnexState :: Annex () -> GlobalSetter -setAnnexState a = GlobalSetter a id - -setAnnexRead :: (AnnexRead -> AnnexRead) -> GlobalSetter -setAnnexRead f = GlobalSetter (return ()) f - -globalFlag :: GlobalSetter -> Mod FlagFields GlobalSetter -> GlobalOption -globalFlag = flag' - -globalOption :: (v -> GlobalSetter) -> Parser v -> GlobalOption -globalOption mk parser = mk <$> parser - --- | Combines a bunch of GlobalOptions together into a Parser --- that returns a GlobalSetter that can be used to set all the options that --- are enabled. -parserGlobalOptions :: [GlobalOption] -> Parser GlobalSetter -parserGlobalOptions [] = pure mempty -parserGlobalOptions l = mconcat <$> many (foldl1 (<|>) l) - -applyAnnexReadSetter :: GlobalSetter -> (AnnexState, AnnexRead) -> (AnnexState, AnnexRead) -applyAnnexReadSetter gs (st, rd) = (st, annexReadSetter gs rd) diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs index 796ea1df3f..a6ff495a2a 100644 --- a/CmdLine/Option.hs +++ b/CmdLine/Option.hs @@ -11,8 +11,7 @@ module CmdLine.Option where import Options.Applicative -import CmdLine.Usage -import CmdLine.GlobalSetter +import CmdLine.AnnexSetter import qualified Annex import Types.Messages import Types.DeferredParse @@ -22,58 +21,50 @@ import Git.Config import Utility.FileSystemEncoding import Annex.Debug --- Global options accepted by both git-annex and git-annex-shell sub-commands. -commonGlobalOptions :: [GlobalOption] -commonGlobalOptions = - [ globalFlag (setforce True) +-- Options accepted by both git-annex and git-annex-shell sub-commands. +commonOptions :: [AnnexOption] +commonOptions = + [ annexFlag (setforce True) ( long "force" <> help "allow actions that may lose annexed data" <> hidden ) - , globalFlag (setfast True) + , annexFlag (setfast True) ( long "fast" <> short 'F' <> help "avoid slow operations" <> hidden ) - , globalFlag (setAnnexState $ Annex.setOutput QuietOutput) + , annexFlag (setAnnexState $ Annex.setOutput QuietOutput) ( long "quiet" <> short 'q' <> help "avoid verbose output" <> hidden ) - , globalFlag (setAnnexState $ Annex.setOutput NormalOutput) + , annexFlag (setAnnexState $ Annex.setOutput NormalOutput) ( long "verbose" <> short 'v' <> help "allow verbose output (default)" <> hidden ) - , globalFlag (setdebug True) + , annexFlag (setdebug True) ( long "debug" <> short 'd' <> help "show debug messages" <> hidden ) - , globalFlag (setdebug False) + , annexFlag (setdebug False) ( long "no-debug" <> help "don't show debug messages" <> hidden ) - , globalOption setdebugfilter $ strOption + , annexOption setdebugfilter $ strOption ( long "debugfilter" <> metavar "NAME[,NAME..]" <> help "show debug messages coming from a module" <> hidden ) - , globalOption setforcebackend $ strOption - ( long "backend" <> short 'b' <> metavar paramName - <> help "specify key-value backend to use" - <> hidden - ) ] where setforce v = setAnnexRead $ \rd -> rd { Annex.force = v } setfast v = setAnnexRead $ \rd -> rd { Annex.fast = v } - setforcebackend v = setAnnexRead $ - \rd -> rd { Annex.forcebackend = Just v } - setdebug v = mconcat [ setAnnexRead $ \rd -> rd { Annex.debugenabled = v } -- Also set in git config so it will be passed on to any diff --git a/Command.hs b/Command.hs index fafe06892c..07cded7fff 100644 --- a/Command.hs +++ b/Command.hs @@ -18,7 +18,7 @@ import CmdLine.Seek as ReExported import CmdLine.Usage as ReExported import CmdLine.Action as ReExported import CmdLine.Option as ReExported -import CmdLine.GlobalSetter as ReExported +import CmdLine.AnnexSetter as ReExported import CmdLine.GitAnnex.Options as ReExported import CmdLine.Batch as ReExported import Options.Applicative as ReExported hiding (command) @@ -69,9 +69,9 @@ noMessages c = c { cmdnomessages = True } noRepo :: (String -> Parser (IO ())) -> Command -> Command noRepo a c = c { cmdnorepo = Just (a (cmdparamdesc c)) } -{- Adds global options to a command. -} -withGlobalOptions :: [[GlobalOption]] -> Command -> Command -withGlobalOptions os c = c { cmdglobaloptions = cmdglobaloptions c ++ concat os } +{- Adds Annex options to a command. -} +withAnnexOptions :: [[AnnexOption]] -> Command -> Command +withAnnexOptions os c = c { cmdannexoptions = cmdannexoptions c ++ concat os } {- For start stage to indicate what will be done. -} starting:: MkActionItem actionitem => String -> actionitem -> SeekInput -> CommandPerform -> CommandStart diff --git a/Command/Add.hs b/Command/Add.hs index 11cf59f3d0..13fc78d018 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -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 diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index 9a09daec2c..371624c065 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -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) diff --git a/Command/CalcKey.hs b/Command/CalcKey.hs index bdae1df5cb..82d3c4c618 100644 --- a/Command/CalcKey.hs +++ b/Command/CalcKey.hs @@ -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 diff --git a/Command/Copy.hs b/Command/Copy.hs index 9e18cf7e2d..bc386894d4 100644 --- a/Command/Copy.hs +++ b/Command/Copy.hs @@ -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) diff --git a/Command/Drop.hs b/Command/Drop.hs index e8fadf83bc..9222ab5a82 100644 --- a/Command/Drop.hs +++ b/Command/Drop.hs @@ -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) diff --git a/Command/DropKey.hs b/Command/DropKey.hs index b84503c331..43de89a970 100644 --- a/Command/DropKey.hs +++ b/Command/DropKey.hs @@ -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) diff --git a/Command/ExamineKey.hs b/Command/ExamineKey.hs index 668a2f5636..bd91a8823e 100644 --- a/Command/ExamineKey.hs +++ b/Command/ExamineKey.hs @@ -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) diff --git a/Command/Export.hs b/Command/Export.hs index b5e6148768..3c5b3ad214 100644 --- a/Command/Export.hs +++ b/Command/Export.hs @@ -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) diff --git a/Command/FilterBranch.hs b/Command/FilterBranch.hs index d72d10cffd..f552e0f4c7 100644 --- a/Command/FilterBranch.hs +++ b/Command/FilterBranch.hs @@ -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) diff --git a/Command/Find.hs b/Command/Find.hs index 271543d1e6..6b4051dc99 100644 --- a/Command/Find.hs +++ b/Command/Find.hs @@ -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 diff --git a/Command/FindRef.hs b/Command/FindRef.hs index f332923309..0009dc2ce0 100644 --- a/Command/FindRef.hs +++ b/Command/FindRef.hs @@ -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) diff --git a/Command/Fix.hs b/Command/Fix.hs index 6220d2fdff..39853c8942 100644 --- a/Command/Fix.hs +++ b/Command/Fix.hs @@ -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) diff --git a/Command/FromKey.hs b/Command/FromKey.hs index 62e15683e5..2f5189acbc 100644 --- a/Command/FromKey.hs +++ b/Command/FromKey.hs @@ -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) diff --git a/Command/Fsck.hs b/Command/Fsck.hs index dbc9d18d0c..cae25dbfaa 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -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) diff --git a/Command/Get.hs b/Command/Get.hs index c3faf308d4..a25fd8bf16 100644 --- a/Command/Get.hs +++ b/Command/Get.hs @@ -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) diff --git a/Command/Import.hs b/Command/Import.hs index db2c970736..692b621c5f 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -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 diff --git a/Command/Info.hs b/Command/Info.hs index caa6a06158..9e47512596 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -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) diff --git a/Command/List.hs b/Command/List.hs index fa57056019..80b0e2db16 100644 --- a/Command/List.hs +++ b/Command/List.hs @@ -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) diff --git a/Command/Lock.hs b/Command/Lock.hs index 6fcd45eb65..d3eb7d3ff6 100644 --- a/Command/Lock.hs +++ b/Command/Lock.hs @@ -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) diff --git a/Command/Log.hs b/Command/Log.hs index 4a87154a76..2520311ea0 100644 --- a/Command/Log.hs +++ b/Command/Log.hs @@ -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) diff --git a/Command/MetaData.hs b/Command/MetaData.hs index cd48734b98..b33e632c73 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -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) diff --git a/Command/Migrate.hs b/Command/Migrate.hs index 25d8c3ba27..0f25b9dac1 100644 --- a/Command/Migrate.hs +++ b/Command/Migrate.hs @@ -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) diff --git a/Command/Mirror.hs b/Command/Mirror.hs index de3248bff3..0699c5e033 100644 --- a/Command/Mirror.hs +++ b/Command/Mirror.hs @@ -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) diff --git a/Command/Move.hs b/Command/Move.hs index 2a74fc525d..56da232d78 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -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) diff --git a/Command/RegisterUrl.hs b/Command/RegisterUrl.hs index 0754f477b5..d82b94cb6d 100644 --- a/Command/RegisterUrl.hs +++ b/Command/RegisterUrl.hs @@ -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) diff --git a/Command/Reinject.hs b/Command/Reinject.hs index ca757a28a4..ad8e908a62 100644 --- a/Command/Reinject.hs +++ b/Command/Reinject.hs @@ -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 diff --git a/Command/Status.hs b/Command/Status.hs index 2925e6332e..0cb1cb0853 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -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) diff --git a/Command/Sync.hs b/Command/Sync.hs index 9cc40afa8b..bad311ed3a 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -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) diff --git a/Command/Unannex.hs b/Command/Unannex.hs index bb98c4960c..0d990da074 100644 --- a/Command/Unannex.hs +++ b/Command/Unannex.hs @@ -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) diff --git a/Command/Unlock.hs b/Command/Unlock.hs index 298721bdd4..7f76fdb033 100644 --- a/Command/Unlock.hs +++ b/Command/Unlock.hs @@ -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 diff --git a/Command/UnregisterUrl.hs b/Command/UnregisterUrl.hs index 35e591a18d..19750c9cc5 100644 --- a/Command/UnregisterUrl.hs +++ b/Command/UnregisterUrl.hs @@ -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) diff --git a/Command/WhereUsed.hs b/Command/WhereUsed.hs index a4c986d8ce..6b70fc54f9 100644 --- a/Command/WhereUsed.hs +++ b/Command/WhereUsed.hs @@ -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) diff --git a/Command/Whereis.hs b/Command/Whereis.hs index d3efb74658..4fe9a0cf16 100644 --- a/Command/Whereis.hs +++ b/Command/Whereis.hs @@ -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) diff --git a/Types/Command.hs b/Types/Command.hs index 96bd5290c3..94e10dfb16 100644 --- a/Types/Command.hs +++ b/Types/Command.hs @@ -87,8 +87,8 @@ data Command = Command -- ^ command line parser , cmdinfomod :: forall a. InfoMod a -- ^ command-specific modifier for ParserInfo - , cmdglobaloptions :: [GlobalOption] - -- ^ additional global options + , cmdannexoptions :: [AnnexOption] + -- ^ additional options not parsed by the CommandParser , cmdnorepo :: Maybe (Parser (IO ())) -- ^used when not in a repo } diff --git a/Types/DeferredParse.hs b/Types/DeferredParse.hs index 58d40f2fc8..9566caefd5 100644 --- a/Types/DeferredParse.hs +++ b/Types/DeferredParse.hs @@ -38,20 +38,20 @@ instance DeferredParseClass (Maybe (DeferredParse a)) where instance DeferredParseClass [DeferredParse a] where finishParse v = mapM finishParse v -type GlobalOption = Parser GlobalSetter +type AnnexOption = Parser AnnexSetter --- Used for global options that can modify Annex state by running +-- Used for options that can modify Annex state by running -- an arbitrary action in it, and can also set up AnnexRead. -data GlobalSetter = GlobalSetter +data AnnexSetter = AnnexSetter { annexStateSetter :: Annex () , annexReadSetter :: AnnexRead -> AnnexRead } -instance Sem.Semigroup GlobalSetter where - a <> b = GlobalSetter +instance Sem.Semigroup AnnexSetter where + a <> b = AnnexSetter { annexStateSetter = annexStateSetter a >> annexStateSetter b , annexReadSetter = annexReadSetter b . annexReadSetter a } -instance Monoid GlobalSetter where - mempty = GlobalSetter (return ()) id +instance Monoid AnnexSetter where + mempty = AnnexSetter (return ()) id diff --git a/doc/bugs/backend_option_for_init_is_in_no_effect__63__.mdwn b/doc/bugs/backend_option_for_init_is_in_no_effect__63__.mdwn index a039cbe72a..7f69f9f678 100644 --- a/doc/bugs/backend_option_for_init_is_in_no_effect__63__.mdwn +++ b/doc/bugs/backend_option_for_init_is_in_no_effect__63__.mdwn @@ -73,3 +73,5 @@ $> grep -r MD5E . ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) kinda + +> [[fixed|done]], --backend is no longer a global option. --[[Joey]] diff --git a/doc/git-annex-common-options.mdwn b/doc/git-annex-common-options.mdwn index 017d85f7b4..0705496035 100644 --- a/doc/git-annex-common-options.mdwn +++ b/doc/git-annex-common-options.mdwn @@ -108,13 +108,6 @@ Most of these options are accepted by all git-annex commands. but now will not do so, because it could lead to data loss, and data loss is now only enabled when using the `--force` option. -* `--backend=name` - - Specifies which key-value backend to use. This can be used when - adding a file to the annex, or migrating a file. Once files - are in the annex, their backend is known and this option is not - necessary. - * `--user-agent=value` Overrides the User-Agent to use when downloading files from the web. diff --git a/doc/git-annex-import.mdwn b/doc/git-annex-import.mdwn index 39e42cefc8..1a8a866c57 100644 --- a/doc/git-annex-import.mdwn +++ b/doc/git-annex-import.mdwn @@ -185,6 +185,10 @@ and `--reinject-duplicates` documentation below. Setting this to "cpus" will run one job per CPU core. +* `--backend` + + Specifies which key-value backend to use for the imported files. + * `--no-check-gitignore` Add gitignored files. diff --git a/doc/git-annex-sync.mdwn b/doc/git-annex-sync.mdwn index 2ad535a99d..aac377f4a1 100644 --- a/doc/git-annex-sync.mdwn +++ b/doc/git-annex-sync.mdwn @@ -167,6 +167,11 @@ have the same value as the currently checked out branch. resolution. It can also be disabled by setting `annex.resolvemerge` to false. +* `--backend` + + Specifies which key-value backend to use when adding files, + or when importing from a special remote. + * `--cleanup` Removes the local and remote `synced/` branches, which were created diff --git a/git-annex.cabal b/git-annex.cabal index 0ce4eb060b..93edbdd94b 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -699,7 +699,7 @@ Executable git-annex CmdLine.GitAnnexShell CmdLine.GitAnnexShell.Checks CmdLine.GitAnnexShell.Fields - CmdLine.GlobalSetter + CmdLine.AnnexSetter CmdLine.Option CmdLine.GitRemoteTorAnnex CmdLine.Seek