#!/usr/bin/python3

import requests, json, sys
from datetime import datetime

class Style:
    '''
    There is REALLY no package that could print things bold...
    So I have to hack this myself using this ugly thing.
    '''
    BOLD = '\033[1m'
    END = '\033[0m'

DAYS = {
    0: 'Poniedziałek',
    1: 'Wtorek',
    2: 'Środa',
    3: 'Czwartek',
    4: 'Piątek'
}

def get_meals_for_day(day):
    meals = [
        'Śniadanie',
        'Obiad',
        'Kolacja'
    ]
    
    for dish in range(len(data[day])):
        print('\t{}: {}'.format(Style.BOLD + meals[dish] + Style.END, data[day][dish]))


if __name__ == '__main__':
    # get data
    response = requests.get('http://ssh.autism-gamers.tk:5000/menu.json')
    data = json.loads(response.text)

    if len(sys.argv) > 1:
        if sys.argv[1] == 'today':
            today = datetime.today().weekday()
            if today > 4:
                print('Jest weekend. Nie ma obiadu!')
            else:
                print(Style.BOLD + 'Dzisiaj:' + Style.END)
                get_meals_for_day(today)
        else:
            print('Nie rozpoznano argumentu')
        
    else:
        # And a loop for printing everything
        for day in range(len(DAYS)):
            print(Style.BOLD + DAYS[day] + Style.END + ':')
            get_meals_for_day(day)
            print()

    # extra line
    print()
