add api-methods list

master
Jordan Orelli 9 years ago
parent bcd00e802e
commit 8da2978b19

@ -4,6 +4,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/jordanorelli/steam" "github.com/jordanorelli/steam"
"os"
"text/tabwriter"
) )
type ApiList struct { 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)
}
}
},
}

@ -17,6 +17,7 @@ func init() {
commands = map[string]command{ commands = map[string]command{
"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,
"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