diff --git a/client/request/request.go b/client/request/request.go index b324994..a79f44f 100644 --- a/client/request/request.go +++ b/client/request/request.go @@ -150,7 +150,7 @@ func (r *Request) newRequest(url string) (*http.Request, error) { func ProcessUnexpectedResponse(resp *Response) { if resp == nil || resp.response == nil { fmt.Println("Response is nil") - os.Exit(0) + os.Exit(1) } //fmt.Println(resp.response.Request.Method + " " + resp.response.Request.URL.Path + " " + strconv.Itoa(resp.response.StatusCode)) @@ -160,26 +160,26 @@ func ProcessUnexpectedResponse(resp *Response) { if resp.response.StatusCode >= http.StatusInternalServerError { fmt.Println("Sorry, something went wrong!") - os.Exit(0) + os.Exit(1) } if resp.response.StatusCode == http.StatusUnauthorized { fmt.Println("Error: Unauthorized to perform this action.\nPlease, make sure that your token is correct and that you have access to this resource.") - os.Exit(0) + os.Exit(1) } var response map[string]interface{} err := json.Unmarshal(resp.body, &response) if err != nil { fmt.Println("Sorry, something went wrong!") - os.Exit(0) + os.Exit(1) } if details, exists := response["details"]; exists { fmt.Println(details) - os.Exit(0) + os.Exit(1) } else { fmt.Println("Sorry, something went wrong!") - os.Exit(0) + os.Exit(1) } } diff --git a/cmd/files/filesCreate.go b/cmd/files/filesCreate.go index 37b93f1..9c53e98 100644 --- a/cmd/files/filesCreate.go +++ b/cmd/files/filesCreate.go @@ -27,6 +27,7 @@ var filesCreateCmd = &cobra.Command{ err := createFile(filePath) if err != nil { fmt.Printf("Error: %s\n", err) + os.Exit(1) } else { fmt.Printf("Uploaded %s successfully\n", filePath) } diff --git a/cmd/files/filesDelete.go b/cmd/files/filesDelete.go index 87a9182..1440695 100644 --- a/cmd/files/filesDelete.go +++ b/cmd/files/filesDelete.go @@ -3,6 +3,7 @@ package files import ( "fmt" "net/http" + "os" "strings" "github.com/spf13/cobra" @@ -20,6 +21,7 @@ var filesDeleteCmd = &cobra.Command{ err := deleteFile(fileName) if err != nil { fmt.Printf("Error: %s\n", err) + os.Exit(1) } else { fmt.Printf("Deleted %s successfully\n", fileName) } diff --git a/cmd/files/filesGet.go b/cmd/files/filesGet.go index 5a8705c..1fdb00f 100644 --- a/cmd/files/filesGet.go +++ b/cmd/files/filesGet.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "os" "strings" "github.com/spf13/cobra" @@ -27,6 +28,7 @@ var filesGetCmd = &cobra.Command{ err := getFile(fileName, outputDir, partialNameMatch) if err != nil { fmt.Printf("Error: %s\n", err) + os.Exit(1) } else { fmt.Printf("Retrieved matches for %s successfully\n", fileName) } diff --git a/cmd/files/filesList.go b/cmd/files/filesList.go index 458583d..92cd5dc 100644 --- a/cmd/files/filesList.go +++ b/cmd/files/filesList.go @@ -3,6 +3,7 @@ package files import ( "encoding/json" "fmt" + "os" "github.com/spf13/cobra" "github.com/trickest/trickest-cli/types" @@ -23,6 +24,7 @@ var filesListCmd = &cobra.Command{ files, err := getMetadata(searchQuery) if err != nil { fmt.Printf("Error: %s\n", err) + os.Exit(1) } else { printFiles(files, jsonOutput) } diff --git a/cmd/library/libraryListModules.go b/cmd/library/libraryListModules.go index 75553ca..01ba96d 100644 --- a/cmd/library/libraryListModules.go +++ b/cmd/library/libraryListModules.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "math" + "os" "github.com/spf13/cobra" "github.com/trickest/trickest-cli/cmd/list" @@ -21,7 +22,8 @@ var libraryListModulesCmd = &cobra.Command{ if len(modules) > 0 { printModules(modules, jsonOutput) } else { - fmt.Println("Couldn't find any workflow in the library!") + fmt.Println("Couldn't find any module in the library!") + os.Exit(1) } }, } diff --git a/cmd/library/libraryListTools.go b/cmd/library/libraryListTools.go index 0188142..30915c5 100644 --- a/cmd/library/libraryListTools.go +++ b/cmd/library/libraryListTools.go @@ -3,6 +3,7 @@ package library import ( "fmt" "math" + "os" "github.com/spf13/cobra" "github.com/trickest/trickest-cli/cmd/list" @@ -19,6 +20,7 @@ var libraryListToolsCmd = &cobra.Command{ PrintTools(tools, jsonOutput) } else { fmt.Println("Couldn't find any tool in the library!") + os.Exit(1) } }, } diff --git a/cmd/library/libraryListWorkflows.go b/cmd/library/libraryListWorkflows.go index 03ba089..7b0a09f 100644 --- a/cmd/library/libraryListWorkflows.go +++ b/cmd/library/libraryListWorkflows.go @@ -3,6 +3,7 @@ package library import ( "encoding/json" "fmt" + "os" "github.com/google/uuid" "github.com/spf13/cobra" @@ -22,6 +23,7 @@ var libraryListWorkflowsCmd = &cobra.Command{ printWorkflows(workflows, jsonOutput) } else { fmt.Println("Couldn't find any workflow in the library!") + os.Exit(1) } }, }