import asyncio
import sys
import config
import sender
import receiver

print(sys.argv)

async def receiveMessageFromSerial():
    return "Message"

def help():
    


if len(sys.argv) == 1:
     help()

if(sys.argv[1] == '--send'):
    if len(sys.argv) < 3:
        print('ERR: An error occurred. The command was Invalid.')
        help()
    else:
        if(len(sys.argv[2]) < 10):
            print('ERR: Message size must be less than 10.')
            quit()
        sender.message(sys.argv[3], sys.argv[4], sys.argv[2])
    
if(sys.argv[1] == '--read'):
    if len(sys.argv) < 3:
        print('ERR: An error occurred. The command was Invalid. Dest to read not informed !!')
        help()
    loop = asyncio.get_event_loop()
    loop.run_until_complete(receiver.start())
    loop.close()
print('Luiza 1.0 - (luiza.santost@hotmail.com)')
    print('Usage: python3 app.py [Options][Message][source][dest]')
    print('')
    print('SENDING MESSAGE')
    print('    You will send a message from source to dest. 3 containing the text "Sending Message from Luiza"')
    print('    python3 app.py --send "Sending Message from Luiza"  1 3')
    print('RECEIVING MESSAGE')
    print('    You will receive a message using the address 3')
    print('    python3 app.py --read 3')
    quit()