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

@ -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