go-mastodon/cmd/mstdn/cmd_search.go

33 lines
645 B
Go
Raw Normal View History

2017-04-15 19:55:32 +02:00
package main
import (
"context"
2017-04-15 19:55:32 +02:00
"errors"
"fmt"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
)
func cmdSearch(c *cli.Context) error {
if !c.Args().Present() {
return errors.New("arguments required")
}
client := c.App.Metadata["client"].(*mastodon.Client)
results, err := client.Search(context.Background(), argstr(c), false)
2017-04-15 19:55:32 +02:00
if err != nil {
return err
}
for _, result := range results.Accounts {
2017-04-16 16:04:31 +02:00
fmt.Fprintln(c.App.Writer, result)
2017-04-15 19:55:32 +02:00
}
for _, result := range results.Statuses {
2017-04-16 16:04:31 +02:00
fmt.Fprintln(c.App.Writer, result)
2017-04-15 19:55:32 +02:00
}
for _, result := range results.Hashtags {
2017-04-16 16:04:31 +02:00
fmt.Fprintln(c.App.Writer, result)
2017-04-15 19:55:32 +02:00
}
return nil
}