import optparse


def connection_options(options, title="Connection Options"):
    """Return an OptionGroup for connection options."""
    group = optparse.OptionGroup(options, title)
    group.add_option("-b", "--bus", action="store", type="string", default="0.0.0.0",
                     metavar="URL", help="URL of the messaging bus to connect to (default %default)")
    group.add_option("-r", "--router", action="store", type="string", default=None,
                     metavar="ROUTER-ID", help="Router to be queried")
    group.add_option("-t", "--timeout", action="store", type="float", default=5, metavar="SECS",
                      help="Maximum time to wait for connection in seconds (default %default)")
    group.add_option("--ssl-certificate", action="store", type="string", metavar="CERT",
                     help="Client SSL certificate (PEM Format)")
    group.add_option("--ssl-key", action="store", type="string", metavar="KEY",
                     help="Client SSL private key (PEM Format)")
    group.add_option("--ssl-trustfile", action="store", type="string", metavar="TRUSTED-CA-DB",
                     help="Trusted Certificate Authority Database file (PEM Format)")
    group.add_option("--ssl-password", action="store", type="string", metavar="PASSWORD",
                     help="Certificate password, will be prompted if not specifed.")
    # Use the --ssl-password-file option to avoid having the --ssl-password in history or scripts.
    group.add_option("--ssl-password-file", action="store", type="string", metavar="SSL-PASSWORD-FILE",
                     help="Certificate password, will be prompted if not specifed.")

    group.add_option("--sasl-mechanisms", action="store", type="string", metavar="SASL-MECHANISMS",
                     help="Allowed sasl mechanisms to be supplied during the sasl handshake.")
    group.add_option("--sasl-username", action="store", type="string", metavar="SASL-USERNAME",
                     help="User name for SASL plain authentication")
    group.add_option("--sasl-password", action="store", type="string", metavar="SASL-PASSWORD",
                     help="Password for SASL plain authentication")
    # Use the --sasl-password-file option to avoid having the --sasl-password in history or scripts.
    group.add_option("--sasl-password-file", action="store", type="string", metavar="SASL-PASSWORD-FILE",
                     help="Password for SASL plain authentication")
    group.add_option("--ssl-disable-peer-name-verify", action="store_true", default=False,
                     help="Disables SSL peer name verification. WARNING - This option is insecure and must not be used "
                          "in production environments")

    return group