add instance_activity/instance_peers command

pull/74/head
Yasuhiro Matsumoto 2018-01-29 13:15:06 +09:00 committed by mattn
parent 84ffd85539
commit 0022a53649
3 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package main
import (
"context"
"fmt"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
)
func cmdInstanceActivity(c *cli.Context) error {
client := c.App.Metadata["client"].(*mastodon.Client)
activities, err := client.GetInstanceActivity(context.Background())
if err != nil {
return err
}
for _, activity := range activities {
fmt.Fprintf(c.App.Writer, "Logins : %v\n", activity.Logins)
fmt.Fprintf(c.App.Writer, "Registrations : %v\n", activity.Registrations)
fmt.Fprintf(c.App.Writer, "Statuses : %v\n", activity.Statuses)
fmt.Fprintf(c.App.Writer, "EMail : %v\n", activity.Week)
}
return nil
}

View File

@ -0,0 +1,21 @@
package main
import (
"context"
"fmt"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
)
func cmdInstancePeers(c *cli.Context) error {
client := c.App.Metadata["client"].(*mastodon.Client)
peers, err := client.GetInstancePeers(context.Background())
if err != nil {
return err
}
for _, peer := range peers {
fmt.Fprintln(c.App.Writer, peer)
}
return nil
}

View File

@ -245,6 +245,16 @@ func makeApp() *cli.App {
Usage: "show instance information",
Action: cmdInstance,
},
{
Name: "instance_activity",
Usage: "show instance activity information",
Action: cmdInstanceActivity,
},
{
Name: "instance_peers",
Usage: "show instance peers information",
Action: cmdInstancePeers,
},
{
Name: "account",
Usage: "show account information",