From 409f4f0aa328be46e301facf22ad7fe320759310 Mon Sep 17 00:00:00 2001 From: Gurvinder Singh Date: Sun, 23 Apr 2017 09:58:56 +0200 Subject: [PATCH] added basic sanity check --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 784bf01..9543abe 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( const srcExtension = "pep.xml" var ( - pepxml = flag.String("pepxml", "test.pep.xml", "path to the pepxml file to index") + pepxml = flag.String("pepxml", "", "path to the pepxml file to index") host = flag.String("host", "http://localhost:9200", "Elasticsearch host with port and protocol information") index = flag.String("index", "promec", "Index name in elasticsearch where xml data will be indexed") dataType = flag.String("datatype", "search_hit", "Data type to be used under index") @@ -47,6 +47,12 @@ func main() { log.SetLevel(lvl) } + if *dirName == "" && *pepxml == "" { + log.Fatal("Provide atleast directory path or Pep XML file to index") + } else if *dirName != "" && *pepxml != "" { + log.Fatal("Provide only one directory path or Pep XML file to index, not both") + } + interval := time.Duration(*sleepInterval) // Create elasticsearch client