implement fastDebug
Most of the changes here involve global option parsing: GlobalSetter changed so it can both run an Annex action to set state, but can also change the AnnexRead value, which is immutable once the Annex monad is running. That allowed a debugselector value to be added to AnnexRead, seeded from the git config. The --debugfilter option's GlobalSetter then updates the AnnexRead. This improved GlobalSetter can later be used to move more stuff to AnnexRead. Things that don't involve a git config will be easier to move, and probably a *lot* of things can be moved eventually. fastDebug, while implemented, is not used anywhere yet. But it should be fast..
This commit is contained in:
parent
6136006106
commit
d16d739ce2
12 changed files with 194 additions and 84 deletions
|
@ -7,19 +7,30 @@
|
|||
|
||||
module CmdLine.GlobalSetter where
|
||||
|
||||
import Types.DeferredParse
|
||||
import Common
|
||||
import Annex
|
||||
import Types.DeferredParse
|
||||
|
||||
import Options.Applicative
|
||||
|
||||
globalFlag :: Annex () -> Mod FlagFields GlobalSetter -> GlobalOption
|
||||
globalFlag setter = flag' (DeferredParse setter)
|
||||
setAnnexState :: Annex () -> GlobalSetter
|
||||
setAnnexState a = GlobalSetter a id
|
||||
|
||||
globalSetter :: (v -> Annex ()) -> Parser v -> GlobalOption
|
||||
globalSetter setter parser = DeferredParse . setter <$> parser
|
||||
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 [] = DeferredParse <$> pure noop
|
||||
parserGlobalOptions l = DeferredParse . mapM_ getParsed
|
||||
<$> many (foldl1 (<|>) l)
|
||||
parserGlobalOptions [] = pure mempty
|
||||
parserGlobalOptions l = mconcat <$> many (foldl1 (<|>) l)
|
||||
|
||||
applyAnnexReadSetter :: GlobalSetter -> (AnnexState, AnnexRead) -> (AnnexState, AnnexRead)
|
||||
applyAnnexReadSetter gs (st, rd) = (st, annexReadSetter gs rd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue