#!/usr/bin/env python3
"""
Python simple Raspberry-Pi camera module web interface
Copyright (C) 2021 Luiz Eduardo Amaral <luizamaral306@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
import argparse

import picamip


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        prog="picamip",
        description="picamip: Python simple Raspberry-Pi camera"
        + " module web interface",
    )
    parser.add_argument(
        "host", nargs="?", default="0.0.0.0", type=str, help="Server host"
    )
    parser.add_argument(
        "port", nargs="?", default=8000, type=int, help="Server port"
    )
    parser.add_argument(
        "-p",
        "--picture-dir",
        default="/home/pi/Pictures",
        type=str,
        help="Pictures storage directory",
    )
    # parser.add_argument(
    #     "-V",
    #     "--video-dir",
    #     default="/home/pi/Videos",
    #     type=str,
    #     help="Videos storage directory",
    # )
    parser.add_argument(
        "-f",
        "--files-prefix",
        default="Picamip_",
        type=str,
        help="Directory to store the pictures. Default: ~/Pictures",
    )
    parser.add_argument(
        "-t",
        "--flask-template",
        type=str,
        help="Flask additional jinja2 templates directory, overwrites defaults.",
    )
    parser.add_argument(
        "-s",
        "--flask-static",
        type=str,
        help="Flask additional static files directory, overwrites defaults.",
    )
    parser.add_argument(
        "-o",
        "--flask-overload",
        type=str,
        help="Flask app functions overload.",
    )
    parser.add_argument(
        "-d",
        "--default-route",
        default="index.html",
        type=str,
        help="Default root route. Eg: index.html",
    )

    parser.add_argument(
        "-v",
        "--version",
        action="version",
        version=f"%(prog)s {picamip.__version__}",
    )

    args = parser.parse_args()

    picamip.run(
        host=args.host,
        port=args.port,
        picture_dir=args.picture_dir,
        files_prefix=args.files_prefix,
        flask_template=args.flask_template,
        flask_static=args.flask_static,
        flask_overload=args.flask_overload,
        default_route=args.default_route,
    )
