enhanced output

This commit is contained in:
2023-03-13 18:48:38 +01:00
parent d6792dd6c8
commit e88399d76d
4 changed files with 33 additions and 18 deletions

View File

@@ -145,17 +145,15 @@ func UploadFiles(c *cfg.Config, args []string) error {
}, 10*time.Millisecond).
Post(rq.Url)
fmt.Println("")
if err != nil {
return err
}
return HandleResponse(c, resp)
return printUploadsResponse(resp)
}
func HandleResponse(c *cfg.Config, resp *req.Response) error {
// we expect a json response
// we expect a json response, extract the error, if any
r := Response{}
if err := json.Unmarshal([]byte(resp.String()), &r); err != nil {
@@ -252,6 +250,10 @@ func Describe(c *cfg.Config, args []string) error {
return err
}
return printUploadsResponse(resp)
}
func printUploadsResponse(resp *req.Response) error {
uploads := Uploads{}
if err := json.Unmarshal([]byte(resp.String()), &uploads); err != nil {
@@ -262,6 +264,10 @@ func Describe(c *cfg.Config, args []string) error {
return errors.New(uploads.Message)
}
if uploads.Message != "" {
fmt.Println(uploads.Message)
}
WriteExtended(&uploads)
return nil