summary refs log tree commit diff stats
path: root/cmd/cetus-nasa
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-14 23:48:47 +0530
committerAndinus <andinus@inventati.org>2020-03-14 23:53:59 +0530
commitddbef09f66e71c2e3172eb876c81a86e89cab7dc (patch)
treeab02e13463372956e03df4feb659b9952cfa4cc0 /cmd/cetus-nasa
parent3d25dff251cde9fad0582fd31e2ad4b95bec0288 (diff)
downloadcetus-ddbef09f66e71c2e3172eb876c81a86e89cab7dc.tar.gz
Add version flag
Diffstat (limited to 'cmd/cetus-nasa')
-rw-r--r--cmd/cetus-nasa/cetus-nasa.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/cmd/cetus-nasa/cetus-nasa.go b/cmd/cetus-nasa/cetus-nasa.go
index 96b83fc..7eb80c2 100644
--- a/cmd/cetus-nasa/cetus-nasa.go
+++ b/cmd/cetus-nasa/cetus-nasa.go
@@ -20,12 +20,14 @@ import (
 	"log"
 	"time"
 
-	"framagit.org/andinus/cetus/pkg"
+	"framagit.org/andinus/cetus/pkg/background"
+	"framagit.org/andinus/cetus/pkg/cetus"
 	"framagit.org/andinus/cetus/pkg/nasa"
 )
 
 var (
 	quiet     bool
+	version   bool
 	fetchOnly bool
 
 	api         string
@@ -38,19 +40,13 @@ var (
 )
 
 func main() {
-	var (
-		picturePath string
-		apodRes     nasa.APOD
-		err         error
-		apodInfo    map[string]string
-	)
-
-	dateHelp = fmt.Sprintf("Choose a random date between 1995-06-16 & %s",
-		time.Now().UTC().Format("2006-01-02"))
-	dateDefault = time.Now().UTC().Format("2006-01-02")
-
 	parseFlags()
 
+	if version {
+		cetus.Version()
+		return
+	}
+
 	// Convert timeout to seconds
 	timeout = timeout * time.Second
 
@@ -58,6 +54,13 @@ func main() {
 		date = nasa.RandDate()
 	}
 
+	var (
+		picturePath string
+		apodRes     nasa.APOD
+		err         error
+		apodInfo    map[string]string
+	)
+
 	apodInfo = make(map[string]string)
 	apodInfo["api"] = api
 	apodInfo["apiKey"] = apiKey
@@ -92,11 +95,17 @@ func main() {
 
 func parseFlags() {
 	flag.BoolVar(&quiet, "quiet", false, "No output")
+	flag.BoolVar(&version, "version", false, "Cetus version")
 	flag.BoolVar(&fetchOnly, "fetch-only", false, "Don't set background, only fetch info")
+
+	dateHelp = fmt.Sprintf("Choose a random date between 1995-06-16 & %s",
+		time.Now().UTC().Format("2006-01-02"))
 	flag.BoolVar(&random, "random", false, dateHelp)
 
 	flag.StringVar(&api, "api", "https://api.nasa.gov/planetary/apod", "APOD API URL")
 	flag.StringVar(&apiKey, "api-key", "DEMO_KEY", "api.nasa.gov key for expanded usage")
+
+	dateDefault = time.Now().UTC().Format("2006-01-02")
 	flag.StringVar(&date, "date", dateDefault, "Date of the APOD image to retrieve")
 
 	flag.DurationVar(&timeout, "timeout", 32*time.Second, "Timeout for http client in seconds")