import: New subcommand, pulls files from a directory outside the annex and adds them

Use case for this was developed somewhere on the Transiberian Railroad.
This commit is contained in:
Joey Hess 2012-05-31 19:47:18 -04:00
parent 3b09281b44
commit 3a10095d40
5 changed files with 61 additions and 1 deletions

10
Seek.hs
View file

@ -4,7 +4,7 @@
- the values a user passes to a command, and prepare actions operating
- on them.
-
- Copyright 2010-2011 Joey Hess <joey@kitenet.net>
- Copyright 2010-2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@ -41,6 +41,14 @@ withFilesNotInGit a params = do
g <- gitRepo
liftIO $ (\p -> LsFiles.notInRepo force p g) l
withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek
withPathContents a params = map a . concat <$> liftIO (mapM get params)
where
get p = ifM (isDirectory <$> getFileStatus p)
( map (\f -> (f, makeRelative p f)) <$> dirContentsRecursive p
, return [(p, takeFileName p)]
)
withWords :: ([String] -> CommandStart) -> CommandSeek
withWords a params = return [a params]