From 22daba466c587222bf11dbad0925b4b8b5d139dd Mon Sep 17 00:00:00 2001 From: Sharpz7 Date: Fri, 5 Nov 2021 11:56:11 +0000 Subject: [PATCH] Fixed bugs on 3.2: Still using remote when it shouldn't be exit doesn't happen on seperate line Add better help for trak Usage with location included --- src/client.go | 6 +++--- src/errors.go | 2 +- src/main.go | 14 ++++++++++---- src/trak.go | 8 ++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/client.go b/src/client.go index 8196705..393f245 100644 --- a/src/client.go +++ b/src/client.go @@ -24,8 +24,8 @@ func client() { var err error var file []byte - if len(secretFlag) != 0 { - resp, err := http.Get(secretFlag) + if len(remoteFile) != 0 { + resp, err := http.Get(remoteFile) handle(err, "Failed to download remote sharpcd.yml") defer resp.Body.Close() @@ -106,7 +106,7 @@ func post(payload postData, url string) (response, int) { // Do Request resp, err := client.Do(req) - handle(err, "Failed to do POST request") + handle(err, "Failed to do POST request to "+url) defer resp.Body.Close() // Read Body and Status diff --git a/src/errors.go b/src/errors.go index b25f0b1..7b8be21 100644 --- a/src/errors.go +++ b/src/errors.go @@ -19,7 +19,7 @@ func handle(e error, msg string) { fmt.Println(e) } ui.Close() - fmt.Print(msg) + fmt.Println(msg) os.Exit(1) } } diff --git a/src/main.go b/src/main.go index a767c28..a74cc2c 100644 --- a/src/main.go +++ b/src/main.go @@ -19,6 +19,7 @@ func init() { // Creates Helper Function flag.Usage = func() { fmt.Println(` + Args of SharpCD: - server: Run the sharpcd server @@ -31,9 +32,14 @@ Args of SharpCD: Sub Command Trak: - - alljobs {type}: Get info on all jobs - - job {type} {id}: Get info on job with logging - - list {type}: Get all jobs running on sharpcd server + - sharpcd trak alljobs {location} {type} + Get info on all jobs + + - sharpcd trak job {location} {type} {id} + Get info on job with logging + + - sharpcd trak list {location} {type} + Get all jobs running on sharpcd server Flags: `) @@ -71,8 +77,8 @@ func main() { case "version": fmt.Println("Version: " + sharpCDVersion) default: - log.Fatal("This subcommand does not exist!") flag.Usage() + log.Fatal("This subcommand does not exist!") } } return diff --git a/src/trak.go b/src/trak.go index 4ce223c..6c2861e 100644 --- a/src/trak.go +++ b/src/trak.go @@ -42,8 +42,8 @@ func trak() { case "list": listJobs() default: - handle(errors.New(""), "No valid trak arg was given") flag.Usage() + handle(errors.New(""), "No valid trak arg was given") } } @@ -51,8 +51,8 @@ func trak() { // Lists all jobs running on server func listJobs() { if len(flag.Args()) < 3 { - handle(errors.New(""), "No valid location was given") flag.Usage() + handle(errors.New(""), "No valid location was given") } var location = flag.Args()[2] @@ -93,8 +93,8 @@ func liveFeed() { var trakOne string = "job" if len(flag.Args()) < 3 { - handle(errors.New(""), "No valid location was given") flag.Usage() + handle(errors.New(""), "No valid location was given") } var trakArg = flag.Args()[1] @@ -111,8 +111,8 @@ func liveFeed() { // Only needed for single job requests if trakArg == trakOne { if len(flag.Args()) < 3 { - handle(errors.New(""), "No valid Job ID was given") flag.Usage() + handle(errors.New(""), "No valid Job ID was given") } var jobID = flag.Args()[3]