added api-params command

master
Jordan Orelli 9 years ago
parent 1e380fbff7
commit 5e8fead0e4

@ -64,6 +64,9 @@ retrieves the list of currently supported api interfaces from steam
var cmd_api_methods = command{ var cmd_api_methods = command{
help: ` help: `
retrieves the list of currently supported api methods from steam. Given an
interface or set of interfaces, returns only the methods defined by those
interfaces.
`, `,
handler: func(c *steam.Client, args ...string) { handler: func(c *steam.Client, args ...string) {
var filter map[string]bool var filter map[string]bool
@ -95,3 +98,50 @@ var cmd_api_methods = command{
} }
}, },
} }
var cmd_api_params = command{
help: `
retrieves the list of currently supported method parameters from steam. Given an interface or set of interfaces, retrieves params for just those interfaces. Given a method or set of methods, retrieves params for just those methods.
retrieve all method parameters for methods in the IDOTA2Match_570 interface:
api-params IDOTA2Match_570
retrieve all method parameters for the IDOTA2Match_570 method GetMatchDetails:
api-params IDOTA2Match_570:GetMatchDetails
`,
handler: func(c *steam.Client, args ...string) {
var filter map[string]bool
if len(args) > 0 {
filter = make(map[string]bool, len(args))
for _, name := range args {
filter[name] = true
}
}
res, err := c.Get("ISteamWebAPIUtil", "GetSupportedAPIList", "v0001")
if err != nil {
bail(1, "error: %s", err)
}
var response struct {
ApiList ApiList `json:"apilist"`
}
if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
bail(1, "error parsing response: %s", err)
}
w := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0)
defer w.Flush()
for _, i := range response.ApiList.Interfaces {
for _, m := range i.Methods {
if filter != nil {
if !(filter[i.Name] || filter[fmt.Sprintf("%s:%s", i.Name, m.Name)]) {
continue
}
}
for _, p := range m.Params {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%t\t%s\n", i.Name, m.Name, p.Name, p.Type, p.Optional, p.Description)
}
}
}
},
}

@ -18,6 +18,7 @@ func init() {
"api-list": cmd_api_list, "api-list": cmd_api_list,
"api-interfaces": cmd_api_interfaces, "api-interfaces": cmd_api_interfaces,
"api-methods": cmd_api_methods, "api-methods": cmd_api_methods,
"api-params": cmd_api_params,
"user-friends": cmd_user_friends, "user-friends": cmd_user_friends,
"user-id": cmd_user_id, "user-id": cmd_user_id,
"user-details": cmd_user_details, "user-details": cmd_user_details,

Loading…
Cancel
Save