from . import MandarinEncode
from sys import argv

if len(argv) < 2:
    print("-- Mandarin database CLI ---")
    print("Usage:")
    print("python -m mandarindb encode [TEXT] - Encodes text to mandarin code")
    print("python -m mandarindb decode [TEXT] - Decodes text from mandarin code")
else:
    cmd = argv[1]
    arg = argv[2]
    if cmd == 'encode':
        print(MandarinEncode.encode(arg))
    elif cmd == 'decode':
        print(MandarinEncode.decode(arg))
    else:
        print(f"Invalid command: \"{cmd}\"")