#!/usr/bin/python
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2012

import os
import sys
from optparse import OptionParser

root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
if os.path.exists(os.path.join(root, 'hostb_client')):
    sys.path.insert(0, root)


import hostb_client

if __name__ == '__main__':
    usage = "usage: %prog [options] filename"
    parser = OptionParser(usage=usage)
    parser.add_option('-u', '--url', dest='url',
        help='base url, defaults to https://hostb.org',
        default='https://hostb.org', type='string')
    parser.add_option('-p', '--password', dest='password',
        help='set password on uploaded file',
        default='', type='string')
    parser.add_option('-d', '--debug', dest='debug',
        help='output debug information', action="store_true")
    (opts, args) = parser.parse_args()

    if None in (opts.url, ) or not args:
        parser.print_help()
        sys.exit()

    client = hostb_client.Client(opts.url)
    for filename in args:
        client.upload(filename, opts.password)
