Esempio n. 1
0
def generate_config(development, output, force):
    """Generates a FlaskBB configuration file."""
    config_env = Environment(loader=FileSystemLoader(
        os.path.join(current_app.root_path, "configs")))
    config_template = config_env.get_template('config.cfg.template')

    if output:
        config_path = os.path.abspath(output)
    else:
        config_path = os.path.dirname(current_app.root_path)

    if os.path.exists(config_path) and not os.path.isfile(config_path):
        config_path = os.path.join(config_path, "flaskbb.cfg")

    # An override to handle database location paths on Windows environments
    database_path = "sqlite:///" + os.path.join(
        os.path.dirname(current_app.instance_path), "flaskbb.sqlite")
    if os.name == 'nt':
        database_path = database_path.replace("\\", r"\\")

    default_conf = {
        "is_debug": True,
        "server_name": "localhost:5000",
        "url_scheme": "http",
        "database_uri": database_path,
        "redis_enabled": False,
        "redis_uri": "redis://*****:*****@yourdomain",
        "mail_admin_address": "admin@yourdomain",
        "secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "csrf_secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "timestamp": datetime.utcnow().strftime("%A, %d. %B %Y at %H:%M"),
        "log_config_path": "",
    }

    if not force:
        config_path = prompt_config_path(config_path)

    if force and os.path.exists(config_path):
        click.secho("Overwriting existing config file: {}".format(config_path),
                    fg="yellow")

    if development:
        write_config(default_conf, config_template, config_path)
        sys.exit(0)

    # SERVER_NAME
    click.secho(
        "The name and port number of the server.\n"
        "This is needed to correctly generate URLs when no request "
        "context is available.",
        fg="cyan")
    default_conf["server_name"] = click.prompt(
        click.style("Server Name", fg="magenta"),
        type=str,
        default=default_conf.get("server_name"))

    # PREFERRED_URL_SCHEME
    click.secho(
        "The URL Scheme is also needed in order to generate correct "
        "URLs when no request context is available.\n"
        "Choose either 'https' or 'http'.",
        fg="cyan")
    default_conf["url_scheme"] = click.prompt(
        click.style("URL Scheme", fg="magenta"),
        type=click.Choice(["https", "http"]),
        default=default_conf.get("url_scheme"))

    # SQLALCHEMY_DATABASE_URI
    click.secho(
        "For Postgres use:\n"
        "    postgresql://flaskbb@localhost:5432/flaskbb\n"
        "For more options see the SQLAlchemy docs:\n"
        "    http://docs.sqlalchemy.org/en/latest/core/engines.html",
        fg="cyan")
    default_conf["database_uri"] = click.prompt(
        click.style("Database URI", fg="magenta"),
        default=default_conf.get("database_uri"))

    # REDIS_ENABLED
    click.secho(
        "Redis will be used for things such as the task queue, "
        "caching and rate limiting.",
        fg="cyan")
    default_conf["redis_enabled"] = click.confirm(
        click.style("Would you like to use redis?", fg="magenta"),
        default=True)  # default_conf.get("redis_enabled") is False

    # REDIS_URI
    if default_conf.get("redis_enabled", False):
        default_conf["redis_uri"] = click.prompt(
            click.style("Redis URI", fg="magenta"),
            default=default_conf.get("redis_uri"))
    else:
        default_conf["redis_uri"] = ""

    # MAIL_SERVER
    click.secho(
        "To use 'localhost' make sure that you have sendmail or\n"
        "something similar installed. Gmail is also supprted.",
        fg="cyan")
    default_conf["mail_server"] = click.prompt(
        click.style("Mail Server", fg="magenta"),
        default=default_conf.get("mail_server"))
    # MAIL_PORT
    click.secho("The port on which the SMTP server is listening on.",
                fg="cyan")
    default_conf["mail_port"] = click.prompt(
        click.style("Mail Server SMTP Port", fg="magenta"),
        default=default_conf.get("mail_port"))
    # MAIL_USE_TLS
    click.secho(
        "If you are using a local SMTP server like sendmail this is "
        "not needed. For external servers it is required.",
        fg="cyan")
    default_conf["mail_use_tls"] = click.confirm(
        click.style("Use TLS for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_tls"))
    # MAIL_USE_SSL
    click.secho("Same as above. TLS is the successor to SSL.", fg="cyan")
    default_conf["mail_use_ssl"] = click.confirm(
        click.style("Use SSL for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_ssl"))
    # MAIL_USERNAME
    click.secho(
        "Not needed if you are using a local smtp server.\nFor gmail "
        "you have to put in your email address here.",
        fg="cyan")
    default_conf["mail_username"] = click.prompt(
        click.style("Mail Username", fg="magenta"),
        default=default_conf.get("mail_username"))
    # MAIL_PASSWORD
    click.secho(
        "Not needed if you are using a local smtp server.\nFor gmail "
        "you have to put in your gmail password here.",
        fg="cyan")
    default_conf["mail_password"] = click.prompt(
        click.style("Mail Password", fg="magenta"),
        default=default_conf.get("mail_password"))
    # MAIL_DEFAULT_SENDER
    click.secho(
        "The name of the sender. You probably want to change it to "
        "something like '<your_community> Mailer'.",
        fg="cyan")
    default_conf["mail_sender_name"] = click.prompt(
        click.style("Mail Sender Name", fg="magenta"),
        default=default_conf.get("mail_sender_name"))
    click.secho(
        "On localhost you want to use a noreply address here. "
        "Use your email address for gmail here.",
        fg="cyan")
    default_conf["mail_sender_address"] = click.prompt(
        click.style("Mail Sender Address", fg="magenta"),
        default=default_conf.get("mail_sender_address"))
    # ADMINS
    click.secho(
        "Logs and important system messages are sent to this address."
        "Use your email address for gmail here.",
        fg="cyan")
    default_conf["mail_admin_address"] = click.prompt(
        click.style("Mail Admin Email", fg="magenta"),
        default=default_conf.get("mail_admin_address"))

    click.secho(
        "Optional filepath to load a logging configuration file from. "
        "See the Python logging documentation for more detail.\n"
        "\thttps://docs.python.org/library/logging.config.html#logging-config-fileformat",
        fg="cyan")
    default_conf["log_config_path"] = click.prompt(
        click.style("Logging Config Path", fg="magenta"),
        default=default_conf.get("log_config_path"))

    write_config(default_conf, config_template, config_path)

    # Finished
    click.secho("The configuration file has been saved to:\n{cfg}\n"
                "Feel free to adjust it as needed.".format(cfg=config_path),
                fg="blue",
                bold=True)
    click.secho("Usage: \nflaskbb --config {cfg} run".format(cfg=config_path),
                fg="green")
Esempio n. 2
0
def generate_config(development, output, force):
    """Generates a FlaskBB configuration file."""
    config_env = Environment(
        loader=FileSystemLoader(os.path.join(current_app.root_path, "configs"))
    )
    config_template = config_env.get_template('config.cfg.template')

    if output:
        config_path = os.path.abspath(output)
    else:
        config_path = os.path.dirname(current_app.root_path)

    if os.path.exists(config_path) and not os.path.isfile(config_path):
        config_path = os.path.join(config_path, "flaskbb.cfg")

    # An override to handle database location paths on Windows environments
    database_path = "sqlite:///" + os.path.join(
        os.path.dirname(current_app.instance_path), "flaskbb.sqlite")
    if os.name == 'nt':
        database_path = database_path.replace("\\", r"\\")

    default_conf = {
        "is_debug": False,
        "server_name": "example.org",
        "use_https": True,
        "database_uri": database_path,
        "redis_enabled": False,
        "redis_uri": "redis://*****:*****@yourdomain",
        "mail_admin_address": "admin@yourdomain",
        "secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "csrf_secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "timestamp": datetime.utcnow().strftime("%A, %d. %B %Y at %H:%M"),
        "log_config_path": "",
        "deprecation_level": "default"
    }

    if not force:
        config_path = prompt_config_path(config_path)

    if force and os.path.exists(config_path):
        click.secho("Overwriting existing config file: {}".format(config_path),
                    fg="yellow")

    if development:
        default_conf["is_debug"] = True
        default_conf["use_https"] = False
        default_conf["server_name"] = "localhost:5000"
        write_config(default_conf, config_template, config_path)
        sys.exit(0)

    # SERVER_NAME
    click.secho("The name and port number of the exposed server.\n"
                "If FlaskBB is accesible on port 80 you can just omit the "
                "port.\n For example, if FlaskBB is accessible via "
                "example.org:8080 than this is also what you would set here.",
                fg="cyan")
    default_conf["server_name"] = click.prompt(
        click.style("Server Name", fg="magenta"), type=str,
        default=default_conf.get("server_name"))

    # HTTPS or HTTP
    click.secho("Is HTTPS (recommended) or HTTP used for to serve FlaskBB?",
                fg="cyan")
    default_conf["use_https"] = click.confirm(
        click.style("Use HTTPS?", fg="magenta"),
        default=default_conf.get("use_https"))

    # SQLALCHEMY_DATABASE_URI
    click.secho("For Postgres use:\n"
                "    postgresql://flaskbb@localhost:5432/flaskbb\n"
                "For more options see the SQLAlchemy docs:\n"
                "    http://docs.sqlalchemy.org/en/latest/core/engines.html",
                fg="cyan")
    default_conf["database_uri"] = click.prompt(
        click.style("Database URI", fg="magenta"),
        default=default_conf.get("database_uri"))

    # REDIS_ENABLED
    click.secho("Redis will be used for things such as the task queue, "
                "caching and rate limiting.", fg="cyan")
    default_conf["redis_enabled"] = click.confirm(
        click.style("Would you like to use redis?", fg="magenta"),
        default=True)  # default_conf.get("redis_enabled") is False

    # REDIS_URI
    if default_conf.get("redis_enabled", False):
        default_conf["redis_uri"] = click.prompt(
            click.style("Redis URI", fg="magenta"),
            default=default_conf.get("redis_uri"))
    else:
        default_conf["redis_uri"] = ""

    # MAIL_SERVER
    click.secho("To use 'localhost' make sure that you have sendmail or\n"
                "something similar installed. Gmail is also supprted.",
                fg="cyan")
    default_conf["mail_server"] = click.prompt(
        click.style("Mail Server", fg="magenta"),
        default=default_conf.get("mail_server"))
    # MAIL_PORT
    click.secho("The port on which the SMTP server is listening on.",
                fg="cyan")
    default_conf["mail_port"] = click.prompt(
        click.style("Mail Server SMTP Port", fg="magenta"),
        default=default_conf.get("mail_port"))
    # MAIL_USE_TLS
    click.secho("If you are using a local SMTP server like sendmail this is "
                "not needed. For external servers it is required.",
                fg="cyan")
    default_conf["mail_use_tls"] = click.confirm(
        click.style("Use TLS for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_tls"))
    # MAIL_USE_SSL
    click.secho("Same as above. TLS is the successor to SSL.", fg="cyan")
    default_conf["mail_use_ssl"] = click.confirm(
        click.style("Use SSL for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_ssl"))
    # MAIL_USERNAME
    click.secho("Not needed if you are using a local smtp server.\nFor gmail "
                "you have to put in your email address here.", fg="cyan")
    default_conf["mail_username"] = click.prompt(
        click.style("Mail Username", fg="magenta"),
        default=default_conf.get("mail_username"))
    # MAIL_PASSWORD
    click.secho("Not needed if you are using a local smtp server.\nFor gmail "
                "you have to put in your gmail password here.", fg="cyan")
    default_conf["mail_password"] = click.prompt(
        click.style("Mail Password", fg="magenta"),
        default=default_conf.get("mail_password"))
    # MAIL_DEFAULT_SENDER
    click.secho("The name of the sender. You probably want to change it to "
                "something like '<your_community> Mailer'.", fg="cyan")
    default_conf["mail_sender_name"] = click.prompt(
        click.style("Mail Sender Name", fg="magenta"),
        default=default_conf.get("mail_sender_name"))
    click.secho("On localhost you want to use a noreply address here. "
                "Use your email address for gmail here.", fg="cyan")
    default_conf["mail_sender_address"] = click.prompt(
        click.style("Mail Sender Address", fg="magenta"),
        default=default_conf.get("mail_sender_address"))
    # ADMINS
    click.secho("Logs and important system messages are sent to this address. "
                "Use your email address for gmail here.", fg="cyan")
    default_conf["mail_admin_address"] = click.prompt(
        click.style("Mail Admin Email", fg="magenta"),
        default=default_conf.get("mail_admin_address"))

    click.secho("Optional filepath to load a logging configuration file from. "
                "See the Python logging documentation for more detail.\n"
                "\thttps://docs.python.org/library/logging.config.html#logging-config-fileformat",  # noqa
                fg="cyan")
    default_conf["log_config_path"] = click.prompt(
        click.style("Logging Config Path", fg="magenta"),
        default=default_conf.get("log_config_path"))

    deprecation_mesg = (
        "Warning level for deprecations. options are: \n"
        "\terror\tturns deprecation warnings into exceptions\n"
        "\tignore\tnever warns about deprecations\n"
        "\talways\talways warns about deprecations even if the warning has been issued\n"  # noqa
        "\tdefault\tshows deprecation warning once per usage\n"
        "\tmodule\tshows deprecation warning once per module\n"
        "\tonce\tonly shows deprecation warning once regardless of location\n"
        "If you are unsure, select default\n"
        "for more details see: https://docs.python.org/3/library/warnings.html#the-warnings-filter"  # noqa
    )

    click.secho(deprecation_mesg, fg="cyan")
    default_conf["deprecation_level"] = click.prompt(
        click.style("Deperecation warning level", fg="magenta"),
        default=default_conf.get("deprecation_level")
    )

    write_config(default_conf, config_template, config_path)

    # Finished
    click.secho("The configuration file has been saved to:\n{cfg}\n"
                "Feel free to adjust it as needed."
                .format(cfg=config_path), fg="blue", bold=True)
    click.secho("Usage: \nflaskbb --config {cfg} run"
                .format(cfg=config_path), fg="green")
Esempio n. 3
0
def generate_config(development, output, force):
    """Generates a FlaskBB configuration file."""
    config_env = Environment(
        loader=FileSystemLoader(os.path.join(current_app.root_path, "configs"))
    )
    config_template = config_env.get_template('config.cfg.template')

    if output:
        config_path = os.path.abspath(output)
    else:
        config_path = os.path.dirname(current_app.root_path)

    if os.path.exists(config_path) and not os.path.isfile(config_path):
        config_path = os.path.join(config_path, "flaskbb.cfg")

    default_conf = {
        "is_debug": True,
        "server_name": "localhost:5000",
        "url_scheme": "http",
        "database_uri": "sqlite:///" + os.path.join(
            os.path.dirname(current_app.root_path), "flaskbb.sqlite"),
        "redis_enabled": False,
        "redis_uri": "redis://*****:*****@yourdomain",
        "mail_admin_address": "admin@yourdomain",
        "secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "csrf_secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "timestamp": datetime.utcnow().strftime("%A, %d. %B %Y at %H:%M")
    }

    if not force:
        config_path = prompt_config_path(config_path)

    if force and os.path.exists(config_path):
        click.secho("Overwriting existing config file: {}".format(config_path),
                    fg="yellow")

    if development:
        write_config(default_conf, config_template, config_path)
        sys.exit(0)

    # SERVER_NAME
    click.secho("The name and port number of the server.\n"
                "This is needed to correctly generate URLs when no request "
                "context is available.", fg="cyan")
    default_conf["server_name"] = click.prompt(
        click.style("Server Name", fg="magenta"), type=str,
        default=default_conf.get("server_name"))

    # PREFERRED_URL_SCHEME
    click.secho("The URL Scheme is also needed in order to generate correct "
                "URLs when no request context is available.\n"
                "Choose either 'https' or 'http'.", fg="cyan")
    default_conf["url_scheme"] = click.prompt(
        click.style("URL Scheme", fg="magenta"),
        type=click.Choice(["https", "http"]),
        default=default_conf.get("url_scheme"))

    # SQLALCHEMY_DATABASE_URI
    click.secho("For Postgres use:\n"
                "    postgresql://flaskbb@localhost:5432/flaskbb\n"
                "For more options see the SQLAlchemy docs:\n"
                "    http://docs.sqlalchemy.org/en/latest/core/engines.html",
                fg="cyan")
    default_conf["database_url"] = click.prompt(
        click.style("Database URI", fg="magenta"),
        default=default_conf.get("database_uri"))

    # REDIS_ENABLED
    click.secho("Redis will be used for things such as the task queue, "
                "caching and rate limiting.", fg="cyan")
    default_conf["redis_enabled"] = click.confirm(
        click.style("Would you like to use redis?", fg="magenta"),
        default=True)  # default_conf.get("redis_enabled") is False

    # REDIS_URI
    if default_conf.get("redis_enabled", False):
        default_conf["redis_uri"] = click.prompt(
            click.style("Redis URI", fg="magenta"),
            default=default_conf.get("redis_uri"))
    else:
        default_conf["redis_uri"] = ""

    # MAIL_SERVER
    click.secho("To use 'localhost' make sure that you have sendmail or\n"
                "something similar installed. Gmail is also supprted.",
                fg="cyan")
    default_conf["mail_server"] = click.prompt(
        click.style("Mail Server", fg="magenta"),
        default=default_conf.get("mail_server"))
    # MAIL_PORT
    click.secho("The port on which the SMTP server is listening on.",
                fg="cyan")
    default_conf["mail_port"] = click.prompt(
        click.style("Mail Server SMTP Port", fg="magenta"),
        default=default_conf.get("mail_port"))
    # MAIL_USE_TLS
    click.secho("If you are using a local SMTP server like sendmail this is "
                "not needed. For external servers this is hopefully required.",
                fg="cyan")
    default_conf["mail_use_tls"] = click.confirm(
        click.style("Use TLS for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_tls"))
    # MAIL_USE_SSL
    click.secho("Same as above. TLS is the successor to SSL.", fg="cyan")
    default_conf["mail_use_ssl"] = click.confirm(
        click.style("Use SSL for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_ssl"))
    # MAIL_USERNAME
    click.secho("Not needed if using a local smtp server. For gmail you have "
                "put in your email address here.", fg="cyan")
    default_conf["mail_username"] = click.prompt(
        click.style("Mail Username", fg="magenta"),
        default=default_conf.get("mail_username"))
    # MAIL_PASSWORD
    click.secho("Not needed if using a local smtp server. For gmail you have "
                "put in your gmail password here.", fg="cyan")
    default_conf["mail_password"] = click.prompt(
        click.style("Mail Password", fg="magenta"),
        default=default_conf.get("mail_password"))
    # MAIL_DEFAULT_SENDER
    click.secho("The name of the sender. You probably want to change it to "
                "something like '<your_community> Mailer'.", fg="cyan")
    default_conf["mail_sender_name"] = click.prompt(
        click.style("Mail Sender Name", fg="magenta"),
        default=default_conf.get("mail_sender_name"))
    click.secho("On localhost you want to use a noreply address here. "
                "Use your email address for gmail here.", fg="cyan")
    default_conf["mail_sender_address"] = click.prompt(
        click.style("Mail Sender Address", fg="magenta"),
        default=default_conf.get("mail_sender_address"))
    # ADMINS
    click.secho("Logs and important system messages are sent to this address."
                "Use your email address for gmail here.", fg="cyan")
    default_conf["mail_admin_address"] = click.prompt(
        click.style("Mail Admin Email", fg="magenta"),
        default=default_conf.get("mail_admin_address"))

    write_config(default_conf, config_template, config_path)

    # Finished
    click.secho("The configuration file has been saved to:\n{cfg}"
                .format(cfg=config_path), fg="blue")
    click.secho("Usage: flaskbb --config {cfg} run\n"
                "Feel free to adjust it as needed."
                .format(cfg=config_path), fg="green")
Esempio n. 4
0
def generate_config(development, output, force):
    """Generates a FlaskBB configuration file."""
    config_env = Environment(loader=FileSystemLoader(
        os.path.join(current_app.root_path, "configs")))
    config_template = config_env.get_template("config.cfg.template")

    if output:
        config_path = os.path.abspath(output)
    else:
        config_path = os.path.dirname(current_app.root_path)

    if os.path.exists(config_path) and not os.path.isfile(config_path):
        config_path = os.path.join(config_path, "flaskbb.cfg")

    # An override to handle database location paths on Windows environments
    database_path = "sqlite:///" + os.path.join(
        os.path.dirname(current_app.instance_path), "flaskbb.sqlite")
    if os.name == "nt":
        database_path = database_path.replace("\\", r"\\")

    default_conf = {
        "is_debug": False,
        "server_name": "example.org",
        "use_https": True,
        "database_uri": database_path,
        "redis_enabled": False,
        "redis_uri": "redis://*****:*****@yourdomain",
        "mail_admin_address": "admin@yourdomain",
        "secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "csrf_secret_key": binascii.hexlify(os.urandom(24)).decode(),
        "timestamp": datetime.utcnow().strftime("%A, %d. %B %Y at %H:%M"),
        "log_config_path": "",
        "deprecation_level": "default",
    }

    if not force:
        config_path = prompt_config_path(config_path)

    if force and os.path.exists(config_path):
        click.secho("Overwriting existing config file: {}".format(config_path),
                    fg="yellow")

    if development:
        default_conf["is_debug"] = True
        default_conf["use_https"] = False
        default_conf["server_name"] = "localhost:5000"
        write_config(default_conf, config_template, config_path)
        sys.exit(0)

    # SERVER_NAME
    click.secho(
        "The name and port number of the exposed server.\n"
        "If FlaskBB is accesible on port 80 you can just omit the "
        "port.\n For example, if FlaskBB is accessible via "
        "example.org:8080 than this is also what you would set here.",
        fg="cyan",
    )
    default_conf["server_name"] = click.prompt(
        click.style("Server Name", fg="magenta"),
        type=str,
        default=default_conf.get("server_name"),
    )

    # HTTPS or HTTP
    click.secho("Is HTTPS (recommended) or HTTP used for to serve FlaskBB?",
                fg="cyan")
    default_conf["use_https"] = click.confirm(
        click.style("Use HTTPS?", fg="magenta"),
        default=default_conf.get("use_https"))

    # SQLALCHEMY_DATABASE_URI
    click.secho(
        "For Postgres use:\n"
        "    postgresql://flaskbb@localhost:5432/flaskbb\n"
        "For more options see the SQLAlchemy docs:\n"
        "    http://docs.sqlalchemy.org/en/latest/core/engines.html",
        fg="cyan",
    )
    default_conf["database_uri"] = click.prompt(
        click.style("Database URI", fg="magenta"),
        default=default_conf.get("database_uri"),
    )

    # REDIS_ENABLED
    click.secho(
        "Redis will be used for things such as the task queue, "
        "caching and rate limiting.",
        fg="cyan",
    )
    default_conf["redis_enabled"] = click.confirm(
        click.style("Would you like to use redis?", fg="magenta"),
        default=True)  # default_conf.get("redis_enabled") is False

    # REDIS_URI
    if default_conf.get("redis_enabled", False):
        default_conf["redis_uri"] = click.prompt(
            click.style("Redis URI", fg="magenta"),
            default=default_conf.get("redis_uri"),
        )
    else:
        default_conf["redis_uri"] = ""

    # MAIL_SERVER
    click.secho(
        "To use 'localhost' make sure that you have sendmail or\n"
        "something similar installed. Gmail is also supprted.",
        fg="cyan",
    )
    default_conf["mail_server"] = click.prompt(
        click.style("Mail Server", fg="magenta"),
        default=default_conf.get("mail_server"),
    )
    # MAIL_PORT
    click.secho("The port on which the SMTP server is listening on.",
                fg="cyan")
    default_conf["mail_port"] = click.prompt(
        click.style("Mail Server SMTP Port", fg="magenta"),
        default=default_conf.get("mail_port"),
    )
    # MAIL_USE_TLS
    click.secho(
        "If you are using a local SMTP server like sendmail this is "
        "not needed. For external servers it is required.",
        fg="cyan",
    )
    default_conf["mail_use_tls"] = click.confirm(
        click.style("Use TLS for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_tls"),
    )
    # MAIL_USE_SSL
    click.secho("Same as above. TLS is the successor to SSL.", fg="cyan")
    default_conf["mail_use_ssl"] = click.confirm(
        click.style("Use SSL for sending mails?", fg="magenta"),
        default=default_conf.get("mail_use_ssl"),
    )
    # MAIL_USERNAME
    click.secho(
        "Not needed if you are using a local smtp server.\nFor gmail "
        "you have to put in your email address here.",
        fg="cyan",
    )
    default_conf["mail_username"] = click.prompt(
        click.style("Mail Username", fg="magenta"),
        default=default_conf.get("mail_username"),
    )
    # MAIL_PASSWORD
    click.secho(
        "Not needed if you are using a local smtp server.\nFor gmail "
        "you have to put in your gmail password here.",
        fg="cyan",
    )
    default_conf["mail_password"] = click.prompt(
        click.style("Mail Password", fg="magenta"),
        default=default_conf.get("mail_password"),
    )
    # MAIL_DEFAULT_SENDER
    click.secho(
        "The name of the sender. You probably want to change it to "
        "something like '<your_community> Mailer'.",
        fg="cyan",
    )
    default_conf["mail_sender_name"] = click.prompt(
        click.style("Mail Sender Name", fg="magenta"),
        default=default_conf.get("mail_sender_name"),
    )
    click.secho(
        "On localhost you want to use a noreply address here. "
        "Use your email address for gmail here.",
        fg="cyan",
    )
    default_conf["mail_sender_address"] = click.prompt(
        click.style("Mail Sender Address", fg="magenta"),
        default=default_conf.get("mail_sender_address"),
    )
    # ADMINS
    click.secho(
        "Logs and important system messages are sent to this address. "
        "Use your email address for gmail here.",
        fg="cyan",
    )
    default_conf["mail_admin_address"] = click.prompt(
        click.style("Mail Admin Email", fg="magenta"),
        default=default_conf.get("mail_admin_address"),
    )

    click.secho(
        "Optional filepath to load a logging configuration file from. "
        "See the Python logging documentation for more detail.\n"
        "\thttps://docs.python.org/library/logging.config.html#logging-config-fileformat",  # noqa
        fg="cyan",
    )
    default_conf["log_config_path"] = click.prompt(
        click.style("Logging Config Path", fg="magenta"),
        default=default_conf.get("log_config_path"),
    )

    deprecation_mesg = (
        "Warning level for deprecations. options are: \n"
        "\terror\tturns deprecation warnings into exceptions\n"
        "\tignore\tnever warns about deprecations\n"
        "\talways\talways warns about deprecations even if the warning has been issued\n"  # noqa
        "\tdefault\tshows deprecation warning once per usage\n"
        "\tmodule\tshows deprecation warning once per module\n"
        "\tonce\tonly shows deprecation warning once regardless of location\n"
        "If you are unsure, select default\n"
        "for more details see: https://docs.python.org/3/library/warnings.html#the-warnings-filter"  # noqa
    )

    click.secho(deprecation_mesg, fg="cyan")
    default_conf["deprecation_level"] = click.prompt(
        click.style("Deperecation warning level", fg="magenta"),
        default=default_conf.get("deprecation_level"),
    )

    write_config(default_conf, config_template, config_path)

    # Finished
    click.secho(
        "The configuration file has been saved to:\n{cfg}\n"
        "Feel free to adjust it as needed.".format(cfg=config_path),
        fg="blue",
        bold=True,
    )
    click.secho("Usage: \nflaskbb --config {cfg} run".format(cfg=config_path),
                fg="green")