Add command tag-list.

This commit is contained in:
voussoir 2021-05-15 18:20:59 -07:00
parent a7b0ae4898
commit 1a944f574e
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -454,6 +454,17 @@ def tag_breplace_argparse(args):
tag.add_synonym(tag_name) tag.add_synonym(tag_name)
photodb.commit() photodb.commit()
def tag_list_argparse(args):
photodb = find_photodb()
tags = photodb.get_all_tag_names()
synonyms = photodb.get_all_synonyms()
keys = sorted(tags.union(synonyms.keys()))
for key in keys:
if key in synonyms:
print(f'{key}={synonyms[key]}')
else:
print(key)
DOCSTRING = ''' DOCSTRING = '''
Etiquette CLI Etiquette CLI
============= =============
@ -490,6 +501,8 @@ Etiquette CLI
{tag_breplace} {tag_breplace}
{tag_list}
At any time, you may add --silent, --quiet, --debug, --loud to change logging. At any time, you may add --silent, --quiet, --debug, --loud to change logging.
You can add --yes to avoid the "Commit?" prompt. You can add --yes to avoid the "Commit?" prompt.
@ -788,6 +801,13 @@ tag_breplace:
> etiquette_cli.py tag_breplace replace_from replace_to > etiquette_cli.py tag_breplace replace_from replace_to
'''.strip(), '''.strip(),
tag_list='''
tag_list:
Show all tags in the database.
> etiquette_cli.py tag_list
'''
) )
DOCSTRING = betterhelp.add_previews(DOCSTRING, SUB_DOCSTRINGS) DOCSTRING = betterhelp.add_previews(DOCSTRING, SUB_DOCSTRINGS)
@ -928,6 +948,9 @@ def main(argv):
p_tag_breplace.add_argument('--yes', dest='autoyes', action='store_true') p_tag_breplace.add_argument('--yes', dest='autoyes', action='store_true')
p_tag_breplace.set_defaults(func=tag_breplace_argparse) p_tag_breplace.set_defaults(func=tag_breplace_argparse)
p_tag_list = subparsers.add_parser('tag_list', aliases=['tag-list'])
p_tag_list.set_defaults(func=tag_list_argparse)
## ##
def pp(args): def pp(args):