summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-30 14:19:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-30 14:19:16 -0400
commit6a5be9d53cad9ee2988c6d54001f387dfe1f2716 (patch)
treebae7346474d2ae932b856f1d70a0fca187ca6454 /Command/Add.hs
parent14d59b40fb4f3a4c9a89266fecae91a0daf08088 (diff)
rename some stuff and prepare to break out more into Command/*
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index d141448a3..08a880206 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -18,14 +18,17 @@ import Types
import Core
import Messages
+command :: Command
+command = Command "add" paramPath seek "add files to annex"
+
{- Add acts on both files not checked into git yet, and unlocked files. -}
-seek :: [SubCmdSeek]
+seek :: [CommandSeek]
seek = [withFilesNotInGit start, withFilesUnlocked start]
{- The add subcommand annexes a file, storing it in a backend, and then
- moving it into the annex directory and setting up the symlink pointing
- to its content. -}
-start :: SubCmdStartBackendFile
+start :: CommandStartBackendFile
start pair@(file, _) = notAnnexed file $ do
s <- liftIO $ getSymbolicLinkStatus file
if (isSymbolicLink s) || (not $ isRegularFile s)
@@ -34,14 +37,14 @@ start pair@(file, _) = notAnnexed file $ do
showStart "add" file
return $ Just $ perform pair
-perform :: BackendFile -> SubCmdPerform
+perform :: BackendFile -> CommandPerform
perform (file, backend) = do
stored <- Backend.storeFileKey file backend
case stored of
Nothing -> return Nothing
Just (key, _) -> return $ Just $ cleanup file key
-cleanup :: FilePath -> Key -> SubCmdCleanup
+cleanup :: FilePath -> Key -> CommandCleanup
cleanup file key = do
moveAnnex key file
logStatus key ValuePresent