diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-04-20 13:49:42 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-04-20 13:50:26 -0400 |
commit | 7accd891d9ecfed1f806ec5657798b93994fea62 (patch) | |
tree | 7470522ddef4491e671fc1d0639e09ecb56e957f /Command/CalcKey.hs | |
parent | 1f9967298f2bb98dd216c08ce049192737a1cf9f (diff) |
calckey: New plumbing command, calculates the key that would be used to refer to a file
Diffstat (limited to 'Command/CalcKey.hs')
-rw-r--r-- | Command/CalcKey.hs | 28 |
1 files changed, 28 insertions, 0 deletions
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 <id@joeyh.name> + - + - 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 |