summaryrefslogtreecommitdiff
path: root/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-26 00:17:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-26 00:17:38 -0400
commit6a97b10fcb3e1fa6a230d92a25b42ded587ff743 (patch)
treeb8a6ce70916c397c67788b47de6a389db8753969 /Command.hs
parent082b022f9ae56b1446b6607cf7851cd4f1d4f904 (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.hs')
-rw-r--r--Command.hs21
1 files changed, 19 insertions, 2 deletions
diff --git a/Command.hs b/Command.hs
index 06fc704bd..cbfb26500 100644
--- a/Command.hs
+++ b/Command.hs
@@ -179,11 +179,11 @@ backendPairs a files = do
filterFiles :: [FilePath] -> Annex [FilePath]
filterFiles l = do
let l' = filter notState l
- exclude <- Annex.flagGet "exclude"
+ exclude <- Annex.getState Annex.exclude
if null exclude
then return l'
else do
- let regexp = compile ("^" ++ wildToRegex exclude) []
+ let regexp = compile (toregex exclude) []
return $ filter (notExcluded regexp) l'
where
notState f = stateLoc /= take stateLocLen f
@@ -191,6 +191,10 @@ filterFiles l = do
notExcluded r f = case match r f [] of
Nothing -> True
Just _ -> False
+ toregex exclude = "^(" ++ toregex' exclude "" ++ ")"
+ toregex' [] c = c
+ toregex' (w:ws) "" = toregex' ws (wildToRegex w)
+ toregex' (w:ws) c = toregex' ws (c ++ "|" ++ wildToRegex w)
{- filter out symlinks -}
notSymlink :: FilePath -> IO Bool
@@ -219,3 +223,16 @@ paramName :: String
paramName = "NAME"
paramNothing :: String
paramNothing = ""
+
+{- The Key specified by the --key and --backend parameters. -}
+cmdlineKey :: Annex Key
+cmdlineKey = do
+ k <- Annex.getState Annex.defaultkey
+ backends <- Backend.list
+ return $ genKey (head backends) (keyname' k)
+ where
+ keyname' Nothing = badkey
+ keyname' (Just "") = badkey
+ keyname' (Just n) = n
+ badkey = error "please specify the key with --key"
+