metadata: add --tag and --untag shorthand options
This commit is contained in:
parent
e7672f197e
commit
d8ce6cac36
2 changed files with 21 additions and 7 deletions
|
@ -17,16 +17,28 @@ import qualified Data.Set as S
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions [setOption] $ command "metadata" paramPaths seek
|
def = [withOptions [setOption, tagOption, untagOption] $
|
||||||
|
command "metadata" paramPaths seek
|
||||||
SectionMetaData "sets metadata of a file"]
|
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
|
||||||
setOption = Option ['s'] ["set"] (ReqArg mkmod "FIELD[+-]=VALUE") "set metadata"
|
setOption = Option ['s'] ["set"] (ReqArg mkmod "FIELD[+-]=VALUE") "set metadata"
|
||||||
where
|
where
|
||||||
mkmod p = case parseModMeta p of
|
mkmod = either error storeModMeta . parseModMeta
|
||||||
Left e -> error e
|
|
||||||
Right modmeta -> Annex.changeState $
|
tagOption :: Option
|
||||||
\s -> s { Annex.modmeta = modmeta:Annex.modmeta s }
|
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 :: CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
|
|
|
@ -708,9 +708,11 @@ subdirectories).
|
||||||
|
|
||||||
To remove a value, use -s field-=value.
|
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 ...]`
|
* `view [field=value ...] [tag ...]`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue