display acct in followers command
parent
18d207636a
commit
adca356db1
|
@ -10,6 +10,8 @@ import (
|
||||||
|
|
||||||
func cmdFollowers(c *cli.Context) error {
|
func cmdFollowers(c *cli.Context) error {
|
||||||
client := c.App.Metadata["client"].(*mastodon.Client)
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
||||||
|
config := c.App.Metadata["config"].(*mastodon.Config)
|
||||||
|
|
||||||
account, err := client.GetAccountCurrentUser(context.Background())
|
account, err := client.GetAccountCurrentUser(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -18,8 +20,9 @@ func cmdFollowers(c *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
s := newScreen(config)
|
||||||
for _, follower := range followers {
|
for _, follower := range followers {
|
||||||
fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, follower.Acct)
|
fmt.Fprintf(c.App.Writer, "%v,%v\n", follower.ID, s.acct(follower.Acct))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestCmdFollowers(t *testing.T) {
|
||||||
fmt.Fprintln(w, `{"id": 123}`)
|
fmt.Fprintln(w, `{"id": 123}`)
|
||||||
return
|
return
|
||||||
case "/api/v1/accounts/123/followers":
|
case "/api/v1/accounts/123/followers":
|
||||||
fmt.Fprintln(w, `[{"id": 234, "username": "zzz"}]`)
|
fmt.Fprintln(w, `[{"id": 234, "username": "ZZZ", "acct": "zzz"}]`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||||
|
|
|
@ -262,13 +262,6 @@ func makeApp() *cli.App {
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
func acct(acct, host string) string {
|
|
||||||
if !strings.Contains(acct, "@") {
|
|
||||||
acct += "@" + host
|
|
||||||
}
|
|
||||||
return acct
|
|
||||||
}
|
|
||||||
|
|
||||||
type screen struct {
|
type screen struct {
|
||||||
host string
|
host string
|
||||||
}
|
}
|
||||||
|
@ -282,6 +275,13 @@ func newScreen(config *mastodon.Config) *screen {
|
||||||
return &screen{host}
|
return &screen{host}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *screen) acct(a string) string {
|
||||||
|
if !strings.Contains(a, "@") {
|
||||||
|
a += "@" + s.host
|
||||||
|
}
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
func (s *screen) displayError(w io.Writer, e error) {
|
func (s *screen) displayError(w io.Writer, e error) {
|
||||||
color.Set(color.FgYellow)
|
color.Set(color.FgYellow)
|
||||||
fmt.Fprintln(w, e.Error())
|
fmt.Fprintln(w, e.Error())
|
||||||
|
@ -291,16 +291,16 @@ func (s *screen) displayError(w io.Writer, e error) {
|
||||||
func (s *screen) displayStatus(w io.Writer, t *mastodon.Status) {
|
func (s *screen) displayStatus(w io.Writer, t *mastodon.Status) {
|
||||||
if t.Reblog != nil {
|
if t.Reblog != nil {
|
||||||
color.Set(color.FgHiRed)
|
color.Set(color.FgHiRed)
|
||||||
fmt.Fprint(w, acct(t.Account.Acct, s.host))
|
fmt.Fprint(w, s.acct(t.Account.Acct))
|
||||||
color.Set(color.Reset)
|
color.Set(color.Reset)
|
||||||
fmt.Fprint(w, " reblogged ")
|
fmt.Fprint(w, " reblogged ")
|
||||||
color.Set(color.FgHiBlue)
|
color.Set(color.FgHiBlue)
|
||||||
fmt.Fprintln(w, acct(t.Reblog.Account.Acct, s.host))
|
fmt.Fprintln(w, s.acct(t.Reblog.Account.Acct))
|
||||||
fmt.Fprintln(w, textContent(t.Reblog.Content))
|
fmt.Fprintln(w, textContent(t.Reblog.Content))
|
||||||
color.Set(color.Reset)
|
color.Set(color.Reset)
|
||||||
} else {
|
} else {
|
||||||
color.Set(color.FgHiRed)
|
color.Set(color.FgHiRed)
|
||||||
fmt.Fprintln(w, acct(t.Account.Acct, s.host))
|
fmt.Fprintln(w, s.acct(t.Account.Acct))
|
||||||
color.Set(color.Reset)
|
color.Set(color.Reset)
|
||||||
fmt.Fprintln(w, textContent(t.Content))
|
fmt.Fprintln(w, textContent(t.Content))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue