Category string `json:"category"`
}
-// AccountCollection is a group of Accounts
-type AccountCollection []Account
-
// Display a single Account
-func (a *Account) Display() string {
+func (a *Account) String() string {
return strings.Join([]string{a.ID, a.Acct}, "\t")
}
return err
}
+// AccountCollection is a group of Accounts
+type AccountCollection []Account
+
// Display a collection of Accounts
func (ac AccountCollection) Display() {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
for _, value := range ac {
- fmt.Fprintln(w, value.Display())
+ fmt.Fprintln(w, value.String())
}
w.Flush()
}
+func (ac AccountCollection) Len() int {
+ return len(ac)
+}
+
+func (ac AccountCollection) Less(i, j int) bool {
+ return ac[i].ID < ac[j].ID
+}
+
+func (ac AccountCollection) Swap(i, j int) {
+ ac[i], ac[j] = ac[j], ac[i]
+}
+
// Authorize opens the default browser to initiate the authorization flow
// for the current user.
func (a *Account) Authorize(host string, app Application) (code string, err error) {
+++ /dev/null
-package mastodon
-
-import (
- "fmt"
- "os"
- "text/tabwriter"
-)
-
-// DisplayItem interface provides a means to display a single item.
-type DisplayItem interface {
- Display() string
-}
-
-// DisplayItemCollection provides a means to display a collection of items.
-type DisplayItemCollection []DisplayItem
-
-func (c DisplayItemCollection) Display() {
- w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
- for _, item := range c {
- fmt.Fprintln(w, item.Display())
- }
- w.Flush()
-}
--- /dev/null
+package display
+
+import (
+ "fmt"
+ "os"
+ "text/tabwriter"
+)
+
+// DisplayItem interface provides a means to display a single item.
+type Item interface {
+ Display() string
+}
+
+// DisplayItemCollection provides a means to display a collection of items.
+type ItemCollection []Item
+
+func AsTable(c ItemCollection) {
+ w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
+ for _, item := range c {
+ fmt.Fprintln(w, item.Display())
+ }
+ w.Flush()
+}
+
+func AsJSON(c ItemCollection) {
+}