git-annex/Command/CalcKey.hs
Joey Hess b223988e22
remove --backend from global options
--backend is no longer a global option, and is only accepted by commands
that actually need it.

Three commands that used to support backend but don't any longer are
watch, webapp, and assistant. It would be possible to make them support it,
but I doubt anyone used the option with these. And in the case of webapp
and assistant, the option was handled inconsistently, only taking affect
when the command is run with an existing git-annex repo, not when it
creates a new one.

Also, renamed GlobalOption etc to AnnexOption. Because there are many
options of this type that are not actually global (any more) and get
added to commands that need them.

Sponsored-by: Kevin Mueller on Patreon
2022-06-29 13:33:25 -04:00

31 lines
764 B
Haskell

{- git-annex command
-
- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Command.CalcKey where
import Command
import Backend (genKey)
import Types.KeySource
import Utility.Metered
cmd :: Command
cmd = noCommit $ noMessages $ dontCheck repoExists $
withAnnexOptions [backendOption] $
command "calckey" SectionPlumbing
"calulate key for a file"
(paramRepeating paramFile)
(batchable run (pure ()))
run :: () -> SeekInput -> String -> Annex Bool
run _ _ file = tryNonAsync (genKey ks nullMeterUpdate Nothing) >>= \case
Right (k, _) -> do
liftIO $ putStrLn $ serializeKey k
return True
Left _err -> return False
where
ks = KeySource file' file' Nothing
file' = toRawFilePath file