diff --git a/cmd/mstdn/cmd_stream.go b/cmd/mstdn/cmd_stream.go index b7122f3..1ba9a6c 100644 --- a/cmd/mstdn/cmd_stream.go +++ b/cmd/mstdn/cmd_stream.go @@ -12,8 +12,15 @@ import ( "github.com/urfave/cli" ) +type SimpleJSON struct { + Username string `json:"username"` + Avatar string `json:"avatar"` + Content string `json:"content"` +} + func cmdStream(c *cli.Context) error { asJSON := c.Bool("json") + asSimpleJSON := c.Bool("simplejson") client := c.App.Metadata["client"].(*mastodon.Client) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -31,6 +38,14 @@ func cmdStream(c *cli.Context) error { for e := range q { if asJSON { json.NewEncoder(c.App.Writer).Encode(e) + } else if asSimpleJSON { + if t, ok := e.(*mastodon.UpdateEvent); ok { + json.NewEncoder(c.App.Writer).Encode(&SimpleJSON{ + Username: t.Status.Account.Username, + Avatar: t.Status.Account.AvatarStatic, + Content: textContent(t.Status.Content), + }) + } } else { switch t := e.(type) { case *mastodon.UpdateEvent: diff --git a/cmd/mstdn/main.go b/cmd/mstdn/main.go index 0e2cb4e..e24586a 100644 --- a/cmd/mstdn/main.go +++ b/cmd/mstdn/main.go @@ -185,6 +185,10 @@ func makeApp() *cli.App { Name: "json", Usage: "output JSON", }, + cli.BoolFlag{ + Name: "simplejson", + Usage: "output simple JSON", + }, }, Action: cmdStream, },