2017-04-15 15:25:20 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-17 04:10:29 +02:00
|
|
|
"context"
|
2017-04-15 15:25:20 +02:00
|
|
|
"fmt"
|
2018-01-29 05:57:17 +01:00
|
|
|
"sort"
|
2017-04-15 15:25:20 +02:00
|
|
|
|
|
|
|
"github.com/mattn/go-mastodon"
|
2022-11-27 05:24:42 +01:00
|
|
|
"github.com/urfave/cli/v2"
|
2017-04-15 15:25:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func cmdInstance(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
2017-04-17 04:10:29 +02:00
|
|
|
instance, err := client.GetInstance(context.Background())
|
2017-04-15 15:25:20 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-04-16 15:27:13 +02:00
|
|
|
fmt.Fprintf(c.App.Writer, "URI : %s\n", instance.URI)
|
|
|
|
fmt.Fprintf(c.App.Writer, "Title : %s\n", instance.Title)
|
|
|
|
fmt.Fprintf(c.App.Writer, "Description: %s\n", instance.Description)
|
|
|
|
fmt.Fprintf(c.App.Writer, "EMail : %s\n", instance.EMail)
|
2018-01-29 05:57:17 +01:00
|
|
|
if instance.Version != "" {
|
|
|
|
fmt.Fprintf(c.App.Writer, "Version : %s\n", instance.Version)
|
|
|
|
}
|
|
|
|
if instance.Thumbnail != "" {
|
|
|
|
fmt.Fprintf(c.App.Writer, "Thumbnail : %s\n", instance.Thumbnail)
|
|
|
|
}
|
|
|
|
if instance.URLs != nil {
|
|
|
|
var keys []string
|
|
|
|
for _, k := range instance.URLs {
|
|
|
|
keys = append(keys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(keys)
|
|
|
|
for _, k := range keys {
|
|
|
|
fmt.Fprintf(c.App.Writer, "%s: %s\n", k, instance.URLs[k])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if instance.Stats != nil {
|
|
|
|
fmt.Fprintf(c.App.Writer, "User Count : %v\n", instance.Stats.UserCount)
|
|
|
|
fmt.Fprintf(c.App.Writer, "Status Count : %v\n", instance.Stats.StatusCount)
|
|
|
|
fmt.Fprintf(c.App.Writer, "Domain Count : %v\n", instance.Stats.DomainCount)
|
|
|
|
}
|
2017-04-15 15:25:20 +02:00
|
|
|
return nil
|
|
|
|
}
|