fix test for search command

This commit is contained in:
Yasuhiro Matsumoto 2017-04-21 00:50:39 +09:00
parent cc593fd21e
commit 6c3b27aa4e
3 changed files with 27 additions and 10 deletions

View file

@ -15,18 +15,33 @@ func cmdSearch(c *cli.Context) error {
}
client := c.App.Metadata["client"].(*mastodon.Client)
config := c.App.Metadata["config"].(*mastodon.Config)
results, err := client.Search(context.Background(), argstr(c), false)
if err != nil {
return err
}
for _, result := range results.Accounts {
fmt.Fprintln(c.App.Writer, result)
s := newScreen(config)
if len(results.Accounts) > 0 {
fmt.Fprintln(c.App.Writer, "===ACCOUNT===")
for _, result := range results.Accounts {
fmt.Fprintf(c.App.Writer, "%v,%v\n", result.ID, s.acct(result.Acct))
}
fmt.Fprintln(c.App.Writer)
}
for _, result := range results.Statuses {
fmt.Fprintln(c.App.Writer, result)
if len(results.Statuses) > 0 {
fmt.Fprintln(c.App.Writer, "===STATUS===")
for _, result := range results.Statuses {
s.displayStatus(c.App.Writer, result)
}
fmt.Fprintln(c.App.Writer)
}
for _, result := range results.Hashtags {
fmt.Fprintln(c.App.Writer, result)
if len(results.Hashtags) > 0 {
fmt.Fprintln(c.App.Writer, "===HASHTAG===")
for _, result := range results.Hashtags {
fmt.Fprintf(c.App.Writer, "#%v\n", result)
}
fmt.Fprintln(c.App.Writer)
}
return nil
}