2021-04-20 10:31:51 +00:00
|
|
|
import sys
|
2021-04-20 11:14:09 +00:00
|
|
|
from urllib.error import URLError
|
|
|
|
|
2021-04-20 09:32:53 +00:00
|
|
|
from antp.exporter import export_note_type
|
2021-04-20 10:31:51 +00:00
|
|
|
from antp.importer import import_note_type
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
try:
|
|
|
|
if len(sys.argv) < 2:
|
2021-11-27 11:16:24 +00:00
|
|
|
print("No action provided.\n")
|
|
|
|
print(f"import\tAdd one of the available note types to Anki.")
|
|
|
|
print(f"export\tSave your note type as a template.")
|
2021-04-20 10:31:51 +00:00
|
|
|
return
|
|
|
|
cmd = sys.argv[1]
|
|
|
|
if cmd == 'export':
|
|
|
|
export_note_type()
|
|
|
|
elif cmd == 'import':
|
|
|
|
import_note_type()
|
|
|
|
except URLError:
|
|
|
|
print("Couldn't connect. Make sure Anki is open and AnkiConnect is installed.")
|
|
|
|
except Exception as ex:
|
|
|
|
print(ex)
|
|
|
|
|
2021-04-20 09:27:48 +00:00
|
|
|
|
2021-04-20 10:31:51 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|