diff options
author | Joey Hess <joey@kitenet.net> | 2014-03-17 15:26:18 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-03-17 15:26:18 -0400 |
commit | 48adf75275455ac7ff3e13d31ee7b1e90818ec40 (patch) | |
tree | 77744ea4fa9670e82775bd588d028d49a03508b4 /Command/MetaData.hs | |
parent | 8d52678e5bc07efa0211e138de76e24f1f34de2e (diff) |
close
Diffstat (limited to 'Command/MetaData.hs')
-rw-r--r-- | Command/MetaData.hs | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Command/MetaData.hs b/Command/MetaData.hs index d49c8429d..46d112162 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -18,10 +18,19 @@ import qualified Data.Set as S import Data.Time.Clock.POSIX def :: [Command] -def = [withOptions [setOption, tagOption, untagOption, getOption, jsonOption] $ +def = [withOptions metaDataOptions $ command "metadata" paramPaths seek SectionMetaData "sets metadata of a file"] +metaDataOptions :: [Option] +metaDataOptions = + [ setOption + , tagOption + , untagOption + , getOption + , jsonOption + ] ++ keyOptions + storeModMeta :: ModMeta -> Annex () storeModMeta modmeta = Annex.changeState $ \s -> s { Annex.modmeta = modmeta:Annex.modmeta s } @@ -50,13 +59,22 @@ seek ps = do getfield <- getOptionField getOption $ \ms -> return $ either error id . mkMetaField <$> ms now <- liftIO getPOSIXTime - withFilesInGit (whenAnnexed $ start now getfield modmeta) ps + withKeyOptions + (startKeys now getfield modmeta) + (withFilesInGit (whenAnnexed $ start now getfield modmeta)) + ps start :: POSIXTime -> Maybe MetaField -> [ModMeta] -> FilePath -> (Key, Backend) -> CommandStart -start now Nothing ms file (k, _) = do - showStart "metadata" file +start now f ms file (k, _) = start' (Just file) now f ms k + +startKeys :: POSIXTime -> Maybe MetaField -> [ModMeta] -> Key -> CommandStart +startKeys = start' Nothing + +start' :: AssociatedFile -> POSIXTime -> Maybe MetaField -> [ModMeta] -> Key -> CommandStart +start' afile now Nothing ms k = do + showStart' "metadata" k afile next $ perform now ms k -start _ (Just f) _ _ (k, _) = do +start' _ _ (Just f) _ k = do l <- S.toList . currentMetaDataValues f <$> getCurrentMetaData k liftIO $ forM_ l $ putStrLn . fromMetaValue |