diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-07-09 19:03:21 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-07-09 19:03:24 -0400 |
commit | ea0f914261e4747de75339952c2d47374c5a7803 (patch) | |
tree | 4af3a12da54d8f40878f1f8d563b8abbd5d0516f /Types | |
parent | 7a5aff2c121f4ecbc173e939b0cf7b2975d18438 (diff) |
wip
Current status:
* building again, but several commands are commented out
* still need to implement global options, file matching options, etc
Diffstat (limited to 'Types')
-rw-r--r-- | Types/DeferredParse.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Types/DeferredParse.hs b/Types/DeferredParse.hs index 2f463de35..4b5ee6d59 100644 --- a/Types/DeferredParse.hs +++ b/Types/DeferredParse.hs @@ -12,6 +12,8 @@ module Types.DeferredParse where import Annex import Common +import Options.Applicative.Types + -- Some values cannot be fully parsed without performing an action. -- The action may be expensive, so it's best to call finishParse on such a -- value before using getParsed repeatedly. @@ -31,3 +33,18 @@ instance DeferredParseClass (DeferredParse a) where instance DeferredParseClass (Maybe (DeferredParse a)) where finishParse Nothing = pure Nothing finishParse (Just v) = Just <$> finishParse v + +instance DeferredParseClass [DeferredParse a] where + finishParse v = mapM finishParse v + +-- Use when the Annex action modifies Annex state. +type GlobalSetter = DeferredParse () + +globalOpt :: Annex () -> Parser Bool -> Parser GlobalSetter +globalOpt setter parser = go <$> parser + where + go False = ReadyParse () + go True = DeferredParse setter + +globalSetter :: (v -> Annex ()) -> Parser v -> Parser GlobalSetter +globalSetter setter parser = DeferredParse . setter <$> parser |