aboutsummaryrefslogtreecommitdiff
path: root/Config.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-29 23:48:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-30 00:28:22 -0400
commit4e9be0d1f86893a469b33b763b55edfe75bdb3aa (patch)
treee721a64007bc52df419a720caf2907dcf62e54ef /Config.hs
parentef5330120c0b522ff159a5b3caba7a926236947b (diff)
refactoring and cleanup
No code changes.
Diffstat (limited to 'Config.hs')
-rw-r--r--Config.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Config.hs b/Config.hs
index f4c3843af..f994002b9 100644
--- a/Config.hs
+++ b/Config.hs
@@ -10,6 +10,7 @@ module Config where
import Common.Annex
import qualified Git
import qualified Annex
+import Types.Key (readKey)
type ConfigKey = String
@@ -92,3 +93,14 @@ getNumCopies v =
return $ read $ Git.configGet g config "1"
config = "annex.numcopies"
+{- The Key specified by the --key parameter. -}
+cmdlineKey :: Annex Key
+cmdlineKey = do
+ k <- Annex.getState Annex.defaultkey
+ case k of
+ Nothing -> nokey
+ Just "" -> nokey
+ Just kstring -> maybe badkey return $ readKey kstring
+ where
+ nokey = error "please specify the key with --key"
+ badkey = error "bad key"