From 8da2978b19f6b3268f3bb0d1cfa3d73fd1e9e612 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Thu, 10 Sep 2015 17:39:37 -0400 Subject: [PATCH] add api-methods list --- cmd/steam/api.go | 26 ++++++++++++++++++++++++++ cmd/steam/commands.go | 1 + 2 files changed, 27 insertions(+) diff --git a/cmd/steam/api.go b/cmd/steam/api.go index 0ce1dcb..49c238a 100644 --- a/cmd/steam/api.go +++ b/cmd/steam/api.go @@ -4,6 +4,8 @@ import ( "encoding/json" "fmt" "github.com/jordanorelli/steam" + "os" + "text/tabwriter" ) type ApiList struct { @@ -59,3 +61,27 @@ retrieves the list of currently supported api interfaces from steam } }, } + +var cmd_api_methods = command{ + help: ` +`, + handler: func(c *steam.Client, args ...string) { + 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 { + fmt.Fprintf(w, "%s\t%s\n", i.Name, m.Name) + } + } + }, +} diff --git a/cmd/steam/commands.go b/cmd/steam/commands.go index 663557f..837a5ac 100644 --- a/cmd/steam/commands.go +++ b/cmd/steam/commands.go @@ -17,6 +17,7 @@ func init() { commands = map[string]command{ "api-list": cmd_api_list, "api-interfaces": cmd_api_interfaces, + "api-methods": cmd_api_methods, "user-friends": cmd_user_friends, "user-id": cmd_user_id, "user-details": cmd_user_details,