#!/usr/bin/env python
'''
download-gmail

Usage:
    download-gmail <database> <email_address> 

Password will be read from EMAIL_PASSWORD, or will be prompted at the command line.
'''

import getpass
import os

import docopt

import mailscanner

if __name__ == '__main__':
    arguments = docopt.docopt(__doc__)
    g = mailscanner.GmailSource(arguments['<email_address>'], os.environ['GMAIL_PASSWORD'] or getpass.getpass())
    gdb = mailscanner.EmailDatabase(arguments['<database>'])
    g.download(gdb)
