From 5e8fead0e4082c584a718db59066f94d4fcac291 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Thu, 10 Sep 2015 18:03:04 -0400 Subject: [PATCH] added api-params command --- cmd/steam/api.go | 50 +++++++++++++++++++++++++++++++++++++++++++ cmd/steam/commands.go | 1 + 2 files changed, 51 insertions(+) diff --git a/cmd/steam/api.go b/cmd/steam/api.go index 598282f..38d5671 100644 --- a/cmd/steam/api.go +++ b/cmd/steam/api.go @@ -64,6 +64,9 @@ retrieves the list of currently supported api interfaces from steam var cmd_api_methods = command{ 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) { 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) + } + } + } + }, +} diff --git a/cmd/steam/commands.go b/cmd/steam/commands.go index 837a5ac..5d76c90 100644 --- a/cmd/steam/commands.go +++ b/cmd/steam/commands.go @@ -18,6 +18,7 @@ func init() { "api-list": cmd_api_list, "api-interfaces": cmd_api_interfaces, "api-methods": cmd_api_methods, + "api-params": cmd_api_params, "user-friends": cmd_user_friends, "user-id": cmd_user_id, "user-details": cmd_user_details,