Check if space track and n2yo creds are present, else prompt the user to enter them

This commit is contained in:
Christopher Woodall
2023-05-14 17:44:59 -05:00
parent c1f3ee10b9
commit e721dcfada
2 changed files with 33 additions and 7 deletions
+30 -4
View File
@@ -1,17 +1,43 @@
/* /*
Copyright © 2023 NAME HERE <EMAIL ADDRESS> Copyright © 2023 Angelina Tsuboi angelinatsuboi@proton.me
*/ */
package main package main
import ( import (
"bufio"
"fmt"
"os" "os"
"strings"
"github.com/ANG13T/SatIntel/cli" "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() { func main() {
os.Setenv("SPACE_TRACK_USERNAME", "username") check_environmental_variable("SPACE_TRACK_USERNAME")
os.Setenv("SPACE_TRACK_PASSWORD", "password") check_environmental_variable("SPACE_TRACK_PASSWORD")
os.Setenv("N2YO_API_KEY", "api-key") check_environmental_variable("N2YO_API_KEY")
cli.SatIntel() cli.SatIntel()
} }
+3 -3
View File
@@ -3,10 +3,10 @@ package osint
import ( import (
"io/ioutil" "io/ioutil"
"fmt" "fmt"
"github.com/iskaa02/qalam/gradient" "github.com/iskaa02/qalam/gradient"
"encoding/json" "encoding/json"
"github.com/TwiN/go-color" "github.com/TwiN/go-color"
"net/http" "net/http"
"strconv" "strconv"
"os" "os"
) )
@@ -31,7 +31,7 @@ func SatellitePositionVisualization() {
var norad string var norad string
fmt.Scanln(&norad) fmt.Scanln(&norad)
GetLocation(norad) GetLocation(norad)
} }
return return
} }