mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-17 04:30:57 +01:00
Changes:
- added describe command - fixed v4+v6 handling
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user