Run an interactive CLI program that
    prints the output of running query() on the input string.

def main():
    """Run an interactive CLI program that
    prints the output of running query() on the input string.
    """
    import sys, signal

    def _exit():
        print("Thank you for playing Simple Mongo Query!")
        sys.exit(0)

    signal.signal(signal.SIGINT, lambda s, f: sys.stdout.write("\n") or _exit())

    while 1:
        expr = input("Enter query: ").strip()
        if not expr:
            break
        try:
            q = to_mongo(expr)
        except BadExpression as e:
            print(("Error! Cannot parse '{}'".format(e.expr)))
            continue
        print(("Result: {}".format(q)))
    _exit()