diff options
author | Joey Hess <joey@kitenet.net> | 2011-01-26 00:17:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-01-26 00:17:38 -0400 |
commit | 6a97b10fcb3e1fa6a230d92a25b42ded587ff743 (patch) | |
tree | b8a6ce70916c397c67788b47de6a389db8753969 /Command/FromKey.hs | |
parent | 082b022f9ae56b1446b6607cf7851cd4f1d4f904 (diff) |
rework config storage
Moved away from a map of flags to storing config directly in the AnnexState
structure. Got rid of most accessor functions in Annex.
This allowed supporting multiple --exclude flags.
Diffstat (limited to 'Command/FromKey.hs')
-rw-r--r-- | Command/FromKey.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Command/FromKey.hs b/Command/FromKey.hs index 9c4a3cfdc..881794258 100644 --- a/Command/FromKey.hs +++ b/Command/FromKey.hs @@ -10,7 +10,7 @@ module Command.FromKey where import Control.Monad.State (liftIO) import System.Posix.Files import System.Directory -import Control.Monad (when, unless) +import Control.Monad (unless) import Command import qualified Annex @@ -30,22 +30,21 @@ seek = [withFilesMissing start] {- Adds a file pointing at a manually-specified key -} start :: CommandStartString start file = do - keyname <- Annex.flagGet "key" - when (null keyname) $ error "please specify the key with --key" - backends <- Backend.list - let key = genKey (head backends) keyname - + key <- cmdlineKey inbackend <- Backend.hasKey key unless inbackend $ error $ - "key ("++keyname++") is not present in backend" + "key ("++keyName key++") is not present in backend" showStart "fromkey" file - return $ Just $ perform file key -perform :: FilePath -> Key -> CommandPerform -perform file key = do + return $ Just $ perform file + +perform :: FilePath -> CommandPerform +perform file = do + key <- cmdlineKey link <- calcGitLink file key liftIO $ createDirectoryIfMissing True (parentDir file) liftIO $ createSymbolicLink link file return $ Just $ cleanup file + cleanup :: FilePath -> CommandCleanup cleanup file = do Annex.queue "add" ["--"] file |