2017-04-15 19:55:32 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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(argstr(c), false)
|
|
|
|
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
|
|
|
|
}
|