def parse_args()

in AWSIoTDeviceDefenderAgentSDK/agent.py [0:0]


def parse_args():
    """Setup Commandline Argument Parsing"""
    parser = argparse.ArgumentParser(fromfile_prefix_chars="@")
    parser.add_argument("-e", "--endpoint", action="store", required=True, dest="endpoint",
                        help="Your AWS IoT custom endpoint, not including a port. " +
                        "Ex: \"abcd123456wxyz-ats.iot.us-east-1.amazonaws.com\"")
    parser.add_argument("-r", "--rootCA", action="store", dest="root_ca_path", required=True,
                        help="File path to root certificate authority, in PEM format. " +
                        "Necessary if MQTT server uses a certificate that's not already in " +
                        "your trust store.")
    parser.add_argument("-c", "--cert", action="store", dest="certificate_path", required=True,
                        help="File path to your client certificate, in PEM format.")
    parser.add_argument("-k", "--key", action="store", dest="private_key_path", required=True,
                        help="File path to your private key, in PEM format.")
    parser.add_argument("-id", "--client_id", action="store", dest="client_id", required=True,
                        help="MQTT Client id, used as thing name for metrics, unless one is passed as a parameter")
    parser.add_argument("-w", '--use-websocket', action="store", dest="use_websocket", default=False,
                        help="To use a websocket instead of raw mqtt. If you " +
                        "specify this option you must specify a region for signing, you can also enable proxy mode.")
    parser.add_argument("-se", '--signing-region', action="store", dest="signing_region", default='us-east-1', help="If you specify --use-web-socket, this " +
                        "is the region that will be used for computing the Sigv4 signature")
    parser.add_argument("-t", "--thing_name", action="store", dest="thing_name", required=False,
                        help="Thing to publish metrics for. If omitted, client_id is assumed")
    parser.add_argument("-d", "--dryrun", action="store_true", dest="dry_run", default=False,
                        help="Collect and print metrics to console, do not publish them over mqtt")
    parser.add_argument("-i", "--interval", action="store", dest="upload_interval", default=300,
                        help="Interval in seconds between metric uploads")
    parser.add_argument("-s", "--short_tags", action="store_true", dest="short_tags", default=False,
                        help="Use long-format field names in metrics report")
    parser.add_argument("-f", "--format", action="store", dest="format", required=True, choices=["cbor", "json"],
                        default='json', help="Choose serialization format for metrics report")
    parser.add_argument('-ph','--proxy-host', action="store", dest="proxy_host", help="Hostname for proxy to connect to. Note: if you use this feature, " +
                        "you will likely need to set --root-ca to the ca for your proxy.")
    parser.add_argument('-pp','--proxy-port', action="store", dest="proxy_port", type=int, default=8080, help="Port for proxy to connect to.")
    parser.add_argument('--verbosity', action="store", dest="verbosity", choices=[x.name for x in io.LogLevel], default=io.LogLevel.NoLogs.name,
                        help='Logging level')
    parser.add_argument('-cm','--include-custom-metrics','--custom-metrics', action="store_true", dest="custom_metrics", default=False, help="Adds custom metrics to payload.")
    return parser.parse_args()