Add remove_tag command.

This commit is contained in:
voussoir 2020-11-27 15:39:58 -08:00
parent f09115d1b8
commit 1cf6e64bfa

View file

@ -126,7 +126,7 @@ def search_by_argparse(args, yield_albums=False, yield_photos=False):
#################################################################################################### ####################################################################################################
def add_tag_argparse(args): def add_remove_tag_argparse(args, action):
photodb = find_photodb() photodb = find_photodb()
tag = photodb.get_tag(name=args.tag_name) tag = photodb.get_tag(name=args.tag_name)
@ -138,7 +138,10 @@ def add_tag_argparse(args):
photos = search_in_cwd(yield_photos=True, yield_albums=False) photos = search_in_cwd(yield_photos=True, yield_albums=False)
for photo in photos: for photo in photos:
if action == 'add':
photo.add_tag(tag) photo.add_tag(tag)
elif action == 'remove':
photo.remove_tag(tag)
if args.autoyes or getpermission.getpermission('Commit?'): if args.autoyes or getpermission.getpermission('Commit?'):
photodb.commit() photodb.commit()
@ -299,7 +302,13 @@ def main(argv):
p_add_tag.add_argument('tag_name') p_add_tag.add_argument('tag_name')
p_add_tag.add_argument('globs', nargs='*') p_add_tag.add_argument('globs', nargs='*')
p_add_tag.add_argument('--yes', dest='autoyes', action='store_true') p_add_tag.add_argument('--yes', dest='autoyes', action='store_true')
p_add_tag.set_defaults(func=add_tag_argparse) p_add_tag.set_defaults(func=lambda args: add_remove_tag_argparse(args, action='add'))
p_remove_tag = subparsers.add_parser('remove_tag', aliases=['remove-tag'])
p_remove_tag.add_argument('tag_name')
p_remove_tag.add_argument('globs', nargs='*')
p_remove_tag.add_argument('--yes', dest='autoyes', action='store_true')
p_remove_tag.set_defaults(func=lambda args: add_remove_tag_argparse(args, action='remove'))
p_easybake = subparsers.add_parser('easybake') p_easybake = subparsers.add_parser('easybake')
p_easybake.add_argument('eb_strings', nargs='+') p_easybake.add_argument('eb_strings', nargs='+')