- added describe command
- fixed v4+v6 handling
This commit is contained in:
2023-03-09 20:24:20 +01:00
parent 01a0dc054d
commit d6792dd6c8
15 changed files with 215 additions and 21 deletions

View File

@@ -59,6 +59,8 @@ type Uploads struct {
Code int `json:"code"`
}
const Maxwidth = 10
func Setup(c *cfg.Config, path string) *Request {
client := req.C()
if c.Debug {
@@ -239,3 +241,28 @@ func Delete(c *cfg.Config, args []string) error {
return nil
}
func Describe(c *cfg.Config, args []string) error {
id := args[0] // we describe only 1 object
rq := Setup(c, "/upload/"+id+"/")
resp, err := rq.R.Get(rq.Url)
if err != nil {
return err
}
uploads := Uploads{}
if err := json.Unmarshal([]byte(resp.String()), &uploads); err != nil {
return errors.New("Could not unmarshall JSON response: " + err.Error())
}
if !uploads.Success {
return errors.New(uploads.Message)
}
WriteExtended(&uploads)
return nil
}