From e721dcfada34155860d6f792db8f74c151bd5f60 Mon Sep 17 00:00:00 2001 From: Christopher Woodall Date: Sun, 14 May 2023 17:44:59 -0500 Subject: [PATCH] Check if space track and n2yo creds are present, else prompt the user to enter them --- main.go | 34 ++++++++++++++++++++++++++++++---- osint/satelliteposition.go | 6 +++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index d4de56e..b91a3c7 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,43 @@ /* -Copyright © 2023 NAME HERE +Copyright © 2023 Angelina Tsuboi angelinatsuboi@proton.me */ package main import ( + "bufio" + "fmt" "os" + "strings" "github.com/ANG13T/SatIntel/cli" ) + +func set_environmental_variable(env_key string) { + reader := bufio.NewReader(os.Stdin) + fmt.Print(env_key + ": ") + input, err := reader.ReadString('\n') + + if err != nil { + fmt.Println("Error reading input:", err) + os.Exit(1) + } + + os.Setenv(env_key, strings.TrimSpace(input)) +} + + +func check_environmental_variable(env_key string) { + if os.Getenv(env_key) == "" { + set_environmental_variable(env_key) + } +} + + func main() { - os.Setenv("SPACE_TRACK_USERNAME", "username") - os.Setenv("SPACE_TRACK_PASSWORD", "password") - os.Setenv("N2YO_API_KEY", "api-key") + check_environmental_variable("SPACE_TRACK_USERNAME") + check_environmental_variable("SPACE_TRACK_PASSWORD") + check_environmental_variable("N2YO_API_KEY") + cli.SatIntel() } diff --git a/osint/satelliteposition.go b/osint/satelliteposition.go index 9044fe2..4fff648 100644 --- a/osint/satelliteposition.go +++ b/osint/satelliteposition.go @@ -3,10 +3,10 @@ package osint import ( "io/ioutil" "fmt" - "github.com/iskaa02/qalam/gradient" + "github.com/iskaa02/qalam/gradient" "encoding/json" "github.com/TwiN/go-color" - "net/http" + "net/http" "strconv" "os" ) @@ -31,7 +31,7 @@ func SatellitePositionVisualization() { var norad string fmt.Scanln(&norad) GetLocation(norad) - } + } return }