summaryrefslogtreecommitdiff
path: root/BackendList.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-11 00:19:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-11 00:19:38 -0400
commit2bd3eea0318fe52452fa7077fe94ae3f224ae9c5 (patch)
tree8597b882848fba48ac67d1ca84361e0dc5c3b516 /BackendList.hs
parentc5d7ca0a5a2c6837d394e23d1a18a1005ee6f1b6 (diff)
add git config lookups for annex.name, annex.backends, etc
Diffstat (limited to 'BackendList.hs')
-rw-r--r--BackendList.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/BackendList.hs b/BackendList.hs
index c744949b6..77e4bd817 100644
--- a/BackendList.hs
+++ b/BackendList.hs
@@ -4,6 +4,7 @@
module BackendList where
-- When adding a new backend, import it here and add it to the list.
+import Types
import qualified BackendFile
import qualified BackendChecksum
import qualified BackendUrl
@@ -12,3 +13,20 @@ supportedBackends =
, BackendChecksum.backend
, BackendUrl.backend
]
+
+{- Parses a string with a list of backend names into
+ - a list of Backend objects. If the list is empty,
+ - defaults to supportedBackends. -}
+parseBackendList :: String -> [Backend]
+parseBackendList s =
+ if (length s == 0)
+ then supportedBackends
+ else map (lookupBackendName) $ words s
+
+{- Looks up a supported backed by name. -}
+lookupBackendName :: String -> Backend
+lookupBackendName s =
+ if ((length matches) /= 1)
+ then error $ "unknown backend " ++ s
+ else matches !! 0
+ where matches = filter (\b -> s == name b) supportedBackends