matchexpression: New plumbing command to check if a preferred content expression matches some data.
This commit is contained in:
parent
4b569c9e7f
commit
d3ba9fe5c8
10 changed files with 186 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex file matcher types
|
||||
-
|
||||
- Copyright 2013 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2013-2016 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -10,13 +10,16 @@ module Types.FileMatcher where
|
|||
import Types.UUID (UUID)
|
||||
import Types.Key (Key)
|
||||
import Utility.Matcher (Matcher, Token)
|
||||
import Utility.FileSize
|
||||
|
||||
import Control.Monad.IO.Class
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
|
||||
data MatchInfo
|
||||
= MatchingFile FileInfo
|
||||
| MatchingKey Key
|
||||
| MatchingInfo (OptInfo FilePath) (OptInfo Key) (OptInfo FileSize)
|
||||
|
||||
data FileInfo = FileInfo
|
||||
{ currFile :: FilePath
|
||||
|
@ -25,6 +28,14 @@ data FileInfo = FileInfo
|
|||
-- ^ filepath to match on; may be relative to top of repo or cwd
|
||||
}
|
||||
|
||||
type OptInfo a = Either (IO a) a
|
||||
|
||||
-- If the OptInfo is not available, accessing it may result in eg an
|
||||
-- exception being thrown.
|
||||
getInfo :: MonadIO m => OptInfo a -> m a
|
||||
getInfo (Right i) = pure i
|
||||
getInfo (Left e) = liftIO e
|
||||
|
||||
type FileMatcherMap a = M.Map UUID (Utility.Matcher.Matcher (S.Set UUID -> MatchInfo -> a Bool))
|
||||
|
||||
type MkLimit a = String -> Either String (MatchFiles a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue