Fix CLI argument logic

This commit is contained in:
Sean Whalen
2018-09-25 14:26:30 -04:00
parent c964241cba
commit eff7c552c9
+5 -9
View File
@@ -164,21 +164,17 @@ def _main():
if args.elasticsearch_host:
elastic.set_hosts(args.elasticsearch_host)
elastic.create_indexes()
if args.hec:
if args.hec_token is None or args.hec_index is None:
logger.error("HEC token and HEC index are required when "
"using HEC URL")
exit(1)
hec_client = splunk.HECClient(args.hec, args.hec_token,
index=args.hec_index)
except ElasticsearchException as error:
logger.error("Elasticsearch Error: {0}".format(error.__str__()))
exit(1)
if args.hec:
if args.hec_key is None:
logger.error("HEC URL provided without HEC key")
if args.hec_token is None or args.hec_index is None:
logger.error("HEC token and HEC index are required when "
"using HEC URL")
exit(1)
hec_client = splunk.HECClient(args.hec, args.hec_token,
args.hec_index)
file_paths = []
for file_path in args.file_path: