import argparse

from instant_rst.config import DEFAULT_FILE, DEFAULT_PORT, DEFAULT_BROWSER, \
    TEMPLATE_DIR, STATIC_DIR

def parse():
    parser = argparse.ArgumentParser(description='Preview rst Instantly')
    parser.add_argument('-f', '--file', dest='filename',
                        default=DEFAULT_FILE,
                        help='The local filename for Converting')
    parser.add_argument('-b', '--browser', dest='browser',
                        default='',
                        help='The browser command for viewing, empty will use default')
    parser.add_argument('-p', '--port', dest='port',
                        default='5676',
                        help='The port for server to use')
    parser.add_argument('-s', '--static-dir', dest='static_dir',
                        default=STATIC_DIR,
                        help='Directory with static files for rendering')
    parser.add_argument('-t', '--template-dir', dest='template_dir',
                        default=TEMPLATE_DIR,
                        help='Directory with template files for rendering')
    parser.add_argument('-l', '--localhost-only', dest='localhost_only',
                        action='store_true',
                        help='Only use localhost, disable lan. default: False')
    parser.add_argument('-d', '--aditional-dir', dest='additional_dirs',
                        action='append',
                        default=[],
                        help='Additional directories to serve')

    parser.add_argument('--debug',
                        action='store_true',
                        default=False,
                        help='debug mode or not')

    return parser.parse_args()
