From 4c8cfa61bfb6fa1d9482a6b07b04d9ec11be4d0d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 6 Feb 2015 15:58:06 -0400 Subject: import: Support file matching options such as --exclude, --include, --smallerthan, --largerthan --- CmdLine/Seek.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'CmdLine/Seek.hs') diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index 4a0bb299b..f3e37969a 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -66,14 +66,20 @@ withFilesInRefs a = mapM_ go void $ commandAction $ a f k withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek -withPathContents a params = seekActions $ - map a . concat <$> liftIO (mapM get params) +withPathContents a params = do + matcher <- Limit.getMatcher + seekActions $ map a <$> (filterM (checkmatch matcher) =<< ps) where + ps = concat <$> liftIO (mapM get params) get p = ifM (isDirectory <$> getFileStatus p) ( map (\f -> (f, makeRelative (parentDir p) f)) <$> dirContentsRecursiveSkipping (".git" `isSuffixOf`) True p , return [(p, takeFileName p)] ) + checkmatch matcher (f, relf) = matcher $ MatchingFile $ FileInfo + { relFile = f + , matchFile = relf + } withWords :: ([String] -> CommandStart) -> CommandSeek withWords a params = seekActions $ return [a params] -- cgit v1.2.3