summary refs log tree commit diff stats
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
parent3d25dff251cde9fad0582fd31e2ad4b95bec0288 (diff)
downloadcetus-ddbef09f66e71c2e3172eb876c81a86e89cab7dc.tar.gz
Add version flag
-rw-r--r--cmd/cetus-nasa/cetus-nasa.go33
-rw-r--r--pkg/background/background.go (renamed from pkg/background.go)0
-rw-r--r--pkg/cetus/cetus.go22
3 files changed, 43 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")
diff --git a/pkg/background.go b/pkg/background/background.go
index c6000ff..c6000ff 100644
--- a/pkg/background.go
+++ b/pkg/background/background.go
diff --git a/pkg/cetus/cetus.go b/pkg/cetus/cetus.go
new file mode 100644
index 0000000..5ebbb63
--- /dev/null
+++ b/pkg/cetus/cetus.go
@@ -0,0 +1,22 @@
+// Copyright (c) 2020, Andinus <andinus@inventati.org>
+
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+package cetus
+
+import "fmt"
+
+// Version prints cetus version
+func Version() {
+	fmt.Println("Cetus v0.4.0")
+}
'#n275'>275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423