diff --git a/antp/__main__.py b/antp/__main__.py index e770632..ab572a9 100644 --- a/antp/__main__.py +++ b/antp/__main__.py @@ -1,11 +1,13 @@ # Copyright: Ren Tatsumoto # License: GNU GPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +import os import sys from typing import Callable from urllib.error import URLError from .common import ANTPError +from .consts import NOTE_TYPES_DIR from .exporter import export_note_type from .importer import import_note_type from .overwriter import overwrite_note_type @@ -31,6 +33,7 @@ def print_help(): ("overwrite", "Overwrite a note type in Anki with new data from a stored note type. " "Fields will not be updated."), ("export", "Save your note type as a template."), + ("list", "List models stored in the templates folder."), ("-v, --verbose", "Show detailed info when errors occur."), ) print( @@ -42,6 +45,10 @@ def print_help(): print(" " * 4, "".join(col.ljust(col_width[i]) for i, col in enumerate(row)), sep='') +def list_stored_note_types(): + print('\n'.join(os.listdir(NOTE_TYPES_DIR))) + + def main(): if len(sys.argv) < 2: print("No action provided.") @@ -61,6 +68,8 @@ def main(): action = update_note_type case 'overwrite': action = overwrite_note_type + case 'list': + action = list_stored_note_types case '-v' | '--verbose': wrap = False