author | Mikael Berthe <mikael@lilotux.net> |
Mon, 19 Mar 2018 15:26:43 +0100 | |
changeset 186 | 180e636f231c |
parent 185 | 564d92b54b00 |
child 190 | e058a8a15e22 |
permissions | -rw-r--r-- |
185 | 1 |
// Copyright © 2017-2018 Mikael Berthe <mikael@lilotux.net> |
0 | 2 |
// |
3 |
// Licensed under the MIT license. |
|
4 |
// Please see the LICENSE file is this directory. |
|
5 |
||
6 |
package cmd |
|
7 |
||
8 |
import ( |
|
37
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
9 |
"os" |
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
10 |
|
0 | 11 |
"github.com/spf13/cobra" |
12 |
) |
|
13 |
||
14 |
// timelinesCmd represents the timelines command |
|
15 |
var instanceCmd = &cobra.Command{ |
|
16 |
Use: "instance", |
|
17 |
Short: "Display current instance information", |
|
38
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
18 |
Long: `Display instance information |
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
19 |
|
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
20 |
This command display the instance information returned by the server. |
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
21 |
`, |
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
22 |
RunE: instanceRunE, |
0 | 23 |
} |
24 |
||
25 |
func init() { |
|
26 |
RootCmd.AddCommand(instanceCmd) |
|
27 |
} |
|
28 |
||
29 |
func instanceRunE(cmd *cobra.Command, args []string) error { |
|
186
180e636f231c
Remove extended statistics using the instances.mastodon.xyz API
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
30 |
if err := madonInit(false); err != nil { |
180e636f231c
Remove extended statistics using the instances.mastodon.xyz API
Mikael Berthe <mikael@lilotux.net>
parents:
185
diff
changeset
|
31 |
return err |
37
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
32 |
} |
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
33 |
|
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
34 |
// Get current instance data through the API |
0 | 35 |
i, err := gClient.GetCurrentInstance() |
36 |
if err != nil { |
|
37 |
errPrint("Error: %s", err.Error()) |
|
47
82d8b6074309
Set exit code to non-zero when API calls fail
Mikael Berthe <mikael@lilotux.net>
parents:
45
diff
changeset
|
38 |
os.Exit(1) |
0 | 39 |
} |
40 |
||
38
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
41 |
p, err := getPrinter() |
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
42 |
if err != nil { |
81
b1671f83e91b
Do not display usage when GetPrinter fails
Mikael Berthe <mikael@lilotux.net>
parents:
47
diff
changeset
|
43 |
errPrint("Error: %s", err.Error()) |
b1671f83e91b
Do not display usage when GetPrinter fails
Mikael Berthe <mikael@lilotux.net>
parents:
47
diff
changeset
|
44 |
os.Exit(1) |
38
891a3c46a62a
Instance stats: sync with gomif update & add time range support
Mikael Berthe <mikael@lilotux.net>
parents:
37
diff
changeset
|
45 |
} |
110 | 46 |
return p.printObj(i) |
0 | 47 |
} |