summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-19 15:04:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-19 15:04:12 -0400
commit22b8d9c7603d6ed610ed9bbc3e59dbdb39e885c5 (patch)
tree4317729e3b08eb4b9fc8d87db68e127c71d572e5 /Command
parent57ab2130132c016790afe800a28c6fd88a5fca7b (diff)
metadata: add --tag and --untag shorthand options
Diffstat (limited to 'Command')
-rw-r--r--Command/MetaData.hs22
1 files changed, 17 insertions, 5 deletions
diff --git a/Command/MetaData.hs b/Command/MetaData.hs
index 23a9bc2b3..6112dd095 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