#!/usr/bin/env python
"""Get menu item details from TouchBistro.

Usage:
    menu [options] changes <db_path>

Options:

 -s, --start=YYYY-MM-DD     Examine menu changes on/after this date
 -c, --cutoff=YYYY-MM-DD    Examine menu changes up to this date (exclusive)
 -d, --debug                Print detailed debug logging
 -j, --json                 Output a JSON summary for the order

"""

import sys
import logging
import json
from docopt import docopt
from touchbistro.menu import get_menu_changes


if __name__ == '__main__':
    ARGS = docopt(__doc__, version='7shifts-load-sales 0.1')
    logging.basicConfig()

    if ARGS.get('--debug', False):
        print(ARGS, file=sys.stderr)
        logging.getLogger().setLevel(logging.DEBUG)

    ORDER = Order(
        ARGS.get('<db_path>'),
        order_number=int(ARGS.get('<order_number>'))
    )

    if ARGS.get('--json'):
        print(json.dumps(
            ORDER.summary(), indent=4, sort_keys=True, default=str))
    else:
        print(ORDER.receipt_form())
    sys.exit(0)
