From 7accd891d9ecfed1f806ec5657798b93994fea62 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 20 Apr 2016 13:49:42 -0400 Subject: calckey: New plumbing command, calculates the key that would be used to refer to a file --- Command/CalcKey.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Command/CalcKey.hs (limited to 'Command') diff --git a/Command/CalcKey.hs b/Command/CalcKey.hs new file mode 100644 index 000000000..e018079cb --- /dev/null +++ b/Command/CalcKey.hs @@ -0,0 +1,28 @@ +{- git-annex command + - + - Copyright 2016 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.CalcKey where + +import Command +import Backend (genKey) +import Types.KeySource + +cmd :: Command +cmd = noCommit $ noMessages $ dontCheck repoExists $ + command "calckey" SectionPlumbing + "calculates the key that would be used to refer to a file" + (paramRepeating paramFile) + (batchable run (pure ())) + +run :: () -> String -> Annex Bool +run _ file = do + mkb <- genKey (KeySource file file Nothing) Nothing + case mkb of + Just (k, _) -> do + liftIO $ putStrLn $ key2file k + return True + Nothing -> return False -- cgit v1.2.3