From e1b7bac4e6bece2464ed383a4d331d2bd2e7a3de Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 16 Apr 2017 23:04:31 +0900 Subject: [PATCH] use writer --- cmd/mstdn/cmd_account.go | 24 ++++++++++++------------ cmd/mstdn/cmd_followers.go | 2 +- cmd/mstdn/cmd_search.go | 6 +++--- cmd/mstdn/cmd_stream.go | 6 +++--- cmd/mstdn/cmd_timeline.go | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cmd/mstdn/cmd_account.go b/cmd/mstdn/cmd_account.go index 4ca9354..e7caa2e 100644 --- a/cmd/mstdn/cmd_account.go +++ b/cmd/mstdn/cmd_account.go @@ -13,17 +13,17 @@ func cmdAccount(c *cli.Context) error { if err != nil { return err } - fmt.Printf("URI : %v\n", account.Acct) - fmt.Printf("ID : %v\n", account.ID) - fmt.Printf("Username : %v\n", account.Username) - fmt.Printf("Acct : %v\n", account.Acct) - fmt.Printf("DisplayName : %v\n", account.DisplayName) - fmt.Printf("Locked : %v\n", account.Locked) - fmt.Printf("CreatedAt : %v\n", account.CreatedAt.Local()) - fmt.Printf("FollowersCount: %v\n", account.FollowersCount) - fmt.Printf("FollowingCount: %v\n", account.FollowingCount) - fmt.Printf("StatusesCount : %v\n", account.StatusesCount) - fmt.Printf("Note : %v\n", account.Note) - fmt.Printf("URL : %v\n", account.URL) + fmt.Fprintf(c.App.Writer, "URI : %v\n", account.Acct) + fmt.Fprintf(c.App.Writer, "ID : %v\n", account.ID) + fmt.Fprintf(c.App.Writer, "Username : %v\n", account.Username) + fmt.Fprintf(c.App.Writer, "Acct : %v\n", account.Acct) + fmt.Fprintf(c.App.Writer, "DisplayName : %v\n", account.DisplayName) + fmt.Fprintf(c.App.Writer, "Locked : %v\n", account.Locked) + fmt.Fprintf(c.App.Writer, "CreatedAt : %v\n", account.CreatedAt.Local()) + fmt.Fprintf(c.App.Writer, "FollowersCount: %v\n", account.FollowersCount) + fmt.Fprintf(c.App.Writer, "FollowingCount: %v\n", account.FollowingCount) + fmt.Fprintf(c.App.Writer, "StatusesCount : %v\n", account.StatusesCount) + fmt.Fprintf(c.App.Writer, "Note : %v\n", account.Note) + fmt.Fprintf(c.App.Writer, "URL : %v\n", account.URL) return nil } diff --git a/cmd/mstdn/cmd_followers.go b/cmd/mstdn/cmd_followers.go index b1ed1ac..aab07ef 100644 --- a/cmd/mstdn/cmd_followers.go +++ b/cmd/mstdn/cmd_followers.go @@ -18,7 +18,7 @@ func cmdFollowers(c *cli.Context) error { return err } for _, follower := range followers { - fmt.Printf("%v,%v\n", follower.ID, follower.Username) + fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, follower.Username) } return nil } diff --git a/cmd/mstdn/cmd_search.go b/cmd/mstdn/cmd_search.go index edb9428..344bbdd 100644 --- a/cmd/mstdn/cmd_search.go +++ b/cmd/mstdn/cmd_search.go @@ -19,13 +19,13 @@ func cmdSearch(c *cli.Context) error { return err } for _, result := range results.Accounts { - fmt.Println(result) + fmt.Fprintln(c.App.Writer, result) } for _, result := range results.Statuses { - fmt.Println(result) + fmt.Fprintln(c.App.Writer, result) } for _, result := range results.Hashtags { - fmt.Println(result) + fmt.Fprintln(c.App.Writer, result) } return nil } diff --git a/cmd/mstdn/cmd_stream.go b/cmd/mstdn/cmd_stream.go index 0779010..6105896 100644 --- a/cmd/mstdn/cmd_stream.go +++ b/cmd/mstdn/cmd_stream.go @@ -29,12 +29,12 @@ func cmdStream(c *cli.Context) error { switch t := e.(type) { case *mastodon.UpdateEvent: color.Set(color.FgHiRed) - fmt.Println(t.Status.Account.Username) + fmt.Fprintln(c.App.Writer, t.Status.Account.Username) color.Set(color.Reset) - fmt.Println(textContent(t.Status.Content)) + fmt.Fprintln(c.App.Writer, textContent(t.Status.Content)) case *mastodon.ErrorEvent: color.Set(color.FgYellow) - fmt.Println(t.Error()) + fmt.Fprintln(c.App.Writer, t.Error()) color.Set(color.Reset) } } diff --git a/cmd/mstdn/cmd_timeline.go b/cmd/mstdn/cmd_timeline.go index be3a10e..6bb2999 100644 --- a/cmd/mstdn/cmd_timeline.go +++ b/cmd/mstdn/cmd_timeline.go @@ -17,9 +17,9 @@ func cmdTimeline(c *cli.Context) error { for i := len(timeline) - 1; i >= 0; i-- { t := timeline[i] color.Set(color.FgHiRed) - fmt.Println(t.Account.Username) + fmt.Fprintln(c.App.Writer, t.Account.Username) color.Set(color.Reset) - fmt.Println(textContent(t.Content)) + fmt.Fprintln(c.App.Writer, textContent(t.Content)) } return nil }