master
Jordan Orelli 9 years ago
parent 910d60d8c0
commit 00b96760c9

@ -15,12 +15,34 @@ var commands map[string]command
func init() {
commands = map[string]command{
"api-list": command{
"api-list": cmd_api_list,
"user-friends": cmd_user_friends,
"user-id": cmd_user_id,
"user-details": cmd_user_details,
"dota-match-history": cmd_dota_match_history,
"dota-match-details": cmd_dota_match_details,
"commands": command{
handler: func(c *steam.Client, args ...string) {
dump(c.Get("ISteamWebAPIUtil", "GetSupportedAPIList", "v0001"))
keys := make([]string, 0, len(commands))
for name, _ := range commands {
keys = append(keys, name)
}
sort.Strings(keys)
for _, key := range keys {
fmt.Println(key)
}
},
},
}
}
var cmd_api_list = command{
handler: func(c *steam.Client, args ...string) {
dump(c.Get("ISteamWebAPIUtil", "GetSupportedAPIList", "v0001"))
},
"user-friends": command{
}
var cmd_user_friends = command{
handler: func(c *steam.Client, args ...string) {
if len(args) < 1 {
bail(1, "please provide a user id")
@ -39,8 +61,9 @@ func init() {
fmt.Fprintln(w, friend.Oneline())
}
},
},
"user-id": command{
}
var cmd_user_id = command{
handler: func(c *steam.Client, args ...string) {
userid, err := c.ResolveVanityUrl(args[0])
if err != nil {
@ -48,8 +71,9 @@ func init() {
}
fmt.Println(userid)
},
},
"user-details": command{
}
var cmd_user_details = command{
handler: func(c *steam.Client, args ...string) {
if len(args) < 1 {
bail(1, "please provide a user id")
@ -72,8 +96,9 @@ func init() {
fmt.Fprintln(w, player.Oneline())
}
},
},
"dota-match-history": command{
}
var cmd_dota_match_history = command{
handler: func(c *steam.Client, args ...string) {
matches, err := c.DotaMatchHistory(0, 0)
if err != nil {
@ -85,8 +110,9 @@ func init() {
fmt.Fprintln(w, match.Oneline())
}
},
},
"dota-match-details": command{
}
var cmd_dota_match_details = command{
handler: func(c *steam.Client, args ...string) {
if len(args) != 1 {
bail(1, "please provide exactly one match id")
@ -101,20 +127,6 @@ func init() {
}
details.Display(os.Stdout)
},
},
"commands": command{
handler: func(c *steam.Client, args ...string) {
keys := make([]string, 0, len(commands))
for name, _ := range commands {
keys = append(keys, name)
}
sort.Strings(keys)
for _, key := range keys {
fmt.Println(key)
}
},
},
}
}
type command struct {

Loading…
Cancel
Save