29 indentInc := " " |
30 indentInc := " " |
30 if option != "" { |
31 if option != "" { |
31 indentInc = option |
32 indentInc = option |
32 } |
33 } |
33 return &PlainPrinter{Indent: indentInc}, nil |
34 return &PlainPrinter{Indent: indentInc}, nil |
|
35 } |
|
36 |
|
37 // InstanceStatistics embeds a gomif.InstanceStatus with an ID in a new type |
|
38 type InstanceStatistics struct { |
|
39 InstanceName string `json:"instance_name"` |
|
40 gomif.InstanceStatus |
34 } |
41 } |
35 |
42 |
36 // PrintObj sends the object as text to the writer |
43 // PrintObj sends the object as text to the writer |
37 // If the writer w is nil, standard output will be used. |
44 // If the writer w is nil, standard output will be used. |
38 // For PlainPrinter, the option parameter contains the initial indent. |
45 // For PlainPrinter, the option parameter contains the initial indent. |
88 return p.plainPrintStatus(&o, w, initialIndent) |
95 return p.plainPrintStatus(&o, w, initialIndent) |
89 case *madon.UserToken: |
96 case *madon.UserToken: |
90 return p.plainPrintUserToken(o, w, initialIndent) |
97 return p.plainPrintUserToken(o, w, initialIndent) |
91 case madon.UserToken: |
98 case madon.UserToken: |
92 return p.plainPrintUserToken(&o, w, initialIndent) |
99 return p.plainPrintUserToken(&o, w, initialIndent) |
|
100 case *InstanceStatistics: |
|
101 return p.plainPrintInstanceStatistics(o, w, initialIndent) |
|
102 case InstanceStatistics: |
|
103 return p.plainPrintInstanceStatistics(&o, w, initialIndent) |
93 } |
104 } |
94 // TODO: Mention |
105 // TODO: Mention |
95 // TODO: StreamEvent |
106 // TODO: StreamEvent |
96 // TODO: Tag |
107 // TODO: Tag |
97 |
108 |
269 indentedPrint(w, indent, false, true, "Timestamp", "%v", time.Unix(int64(s.CreatedAt), 0)) |
280 indentedPrint(w, indent, false, true, "Timestamp", "%v", time.Unix(int64(s.CreatedAt), 0)) |
270 } |
281 } |
271 indentedPrint(w, indent, false, true, "Scope", "%s", s.Scope) |
282 indentedPrint(w, indent, false, true, "Scope", "%s", s.Scope) |
272 return nil |
283 return nil |
273 } |
284 } |
|
285 |
|
286 func (p *PlainPrinter) plainPrintInstanceStatistics(is *InstanceStatistics, w io.Writer, indent string) error { |
|
287 indentedPrint(w, indent, true, false, "Instance", "%s", is.InstanceName) |
|
288 indentedPrint(w, indent, false, false, "Users", "%d", is.Users) |
|
289 indentedPrint(w, indent, false, false, "Statuses", "%d", is.Statuses) |
|
290 indentedPrint(w, indent, false, false, "Open Registrations", "%v", is.OpenRegistrations) |
|
291 indentedPrint(w, indent, false, false, "Up", "%v", is.Up) |
|
292 indentedPrint(w, indent, false, false, "Date", "%s", time.Unix(is.Date, 0)) |
|
293 return nil |
|
294 } |