diff --git a/Command/MetaData.hs b/Command/MetaData.hs index 23a9bc2b34..6112dd0951 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -17,16 +17,28 @@ import qualified Data.Set as S import Data.Time.Clock.POSIX def :: [Command] -def = [withOptions [setOption] $ command "metadata" paramPaths seek +def = [withOptions [setOption, tagOption, untagOption] $ + command "metadata" paramPaths seek SectionMetaData "sets metadata of a file"] +storeModMeta :: ModMeta -> Annex () +storeModMeta modmeta = Annex.changeState $ + \s -> s { Annex.modmeta = modmeta:Annex.modmeta s } + setOption :: Option setOption = Option ['s'] ["set"] (ReqArg mkmod "FIELD[+-]=VALUE") "set metadata" where - mkmod p = case parseModMeta p of - Left e -> error e - Right modmeta -> Annex.changeState $ - \s -> s { Annex.modmeta = modmeta:Annex.modmeta s } + mkmod = either error storeModMeta . parseModMeta + +tagOption :: Option +tagOption = Option ['t'] ["tag"] (ReqArg mkmod "TAG") "set a tag" + where + mkmod = storeModMeta . AddMeta tagMetaField . toMetaValue + +untagOption :: Option +untagOption = Option ['u'] ["untag"] (ReqArg mkmod "TAG") "remove a tag" + where + mkmod = storeModMeta . AddMeta tagMetaField . mkMetaValue (CurrentlySet False) seek :: CommandSeek seek ps = do diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 6306a742af..23002cb9ac 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -708,9 +708,11 @@ subdirectories). To remove a value, use -s field-=value. - For example, to set some tags on a file: + To set a tag, use -t tag, and use -u tag to remove a tag. - git annex metadata annexscreencast.ogv -s tag+=video -s tag+=screencast + For example, to set some tags on a file and also its author: + + git annex metadata annexscreencast.ogv -t video -t screencast -s author+=Alice * `view [field=value ...] [tag ...]`