diff options
author | Joey Hess <joey@kitenet.net> | 2013-10-28 14:08:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-10-28 14:08:38 -0400 |
commit | a86cd4bc8215f01ffe2ba06c63be56656d8ae7cf (patch) | |
tree | fb66e5b0ae237b6b1b017f1bff75ffc15cec87a1 /Command/Wanted.hs | |
parent | 061fbfb37e02a9a9cb42396cce63d9b67d6a9c6e (diff) |
The "git annex content" command is renamed to "git annex wanted".
Diffstat (limited to 'Command/Wanted.hs')
-rw-r--r-- | Command/Wanted.hs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Command/Wanted.hs b/Command/Wanted.hs new file mode 100644 index 000000000..a7b4a3d9e --- /dev/null +++ b/Command/Wanted.hs @@ -0,0 +1,48 @@ +{- git-annex command + - + - Copyright 2013 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.Wanted where + +import Common.Annex +import Command +import qualified Remote +import Logs.PreferredContent + +import qualified Data.Map as M + +def :: [Command] +def = [command "wanted" (paramPair paramRemote (paramOptional paramExpression)) seek + SectionSetup "get or set preferred content expression"] + +seek :: [CommandSeek] +seek = [withWords start] + +start :: [String] -> CommandStart +start = parse + where + parse (name:[]) = go name performGet + parse (name:expr:[]) = go name $ \uuid -> do + showStart "wanted" name + performSet expr uuid + parse _ = error "Specify a repository." + + go name a = do + u <- Remote.nameToUUID name + next $ a u + +performGet :: UUID -> CommandPerform +performGet uuid = do + m <- preferredContentMapRaw + liftIO $ putStrLn $ fromMaybe "" $ M.lookup uuid m + next $ return True + +performSet :: String -> UUID -> CommandPerform +performSet expr uuid = case checkPreferredContentExpression expr of + Just e -> error $ "Parse error: " ++ e + Nothing -> do + preferredContentSet uuid expr + next $ return True |