#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
urlextract - command line program that will print all URLs to stdout

Usage: urlextract INPUT_FILE

INPUT FILE - text file with URLs to extract

.. Created on 2016-07-29
.. Licence MIT
.. codeauthor:: Jan Lipovský <janlipovsky@gmail.com>, janlipovsky.cz
"""

import argparse

from urlextract import URLExtract


def get_args():
    """
    Parse programs arguments
    """
    parser = argparse.ArgumentParser(description='urlextract - prints out all URLs that were found in input file')

    parser.add_argument("-v", "--version", action="version",
                        version='%(prog)s - version {}'.format(URLExtract.get_version()))

    parser.add_argument(type=str, default=None, metavar='<input_file>', dest='input_file',
                        help='input text file with URLs to extract. [UTF-8]')

    parsed_args = parser.parse_args()
    return parsed_args


if __name__ == '__main__':
    args = get_args()

    urlextract = URLExtract()
    with open(args.input_file, "r", encoding="UTF-8") as f:
        content = f.read()
        print(urlextract.find_urls(content))
