2015-04-03 05:21:33 +00:00
|
|
|
package api
|
|
|
|
|
2015-04-03 05:26:34 +00:00
|
|
|
import (
|
2018-07-24 22:49:55 +00:00
|
|
|
"context"
|
2015-04-03 05:26:34 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2015-04-03 05:21:33 +00:00
|
|
|
// Help reads the help information for the given path.
|
2015-04-03 05:26:34 +00:00
|
|
|
func (c *Client) Help(path string) (*Help, error) {
|
2015-04-03 05:42:05 +00:00
|
|
|
r := c.NewRequest("GET", fmt.Sprintf("/v1/%s", path))
|
|
|
|
r.Params.Add("help", "1")
|
2018-07-24 22:49:55 +00:00
|
|
|
|
|
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
|
|
defer cancelFunc()
|
|
|
|
resp, err := c.RawRequestWithContext(ctx, r)
|
2015-04-03 05:26:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
var result Help
|
|
|
|
err = resp.DecodeJSON(&result)
|
|
|
|
return &result, err
|
|
|
|
}
|
|
|
|
|
|
|
|
type Help struct {
|
|
|
|
Help string `json:"help"`
|
|
|
|
SeeAlso []string `json:"see_also"`
|
2015-04-03 05:21:33 +00:00
|
|
|
}
|