-
Notifications
You must be signed in to change notification settings - Fork 7
/
accounts.go
43 lines (33 loc) · 924 Bytes
/
accounts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package commands
import (
"os"
"strconv"
"github.com/alecthomas/kong"
"github.com/section/sectionctl/api"
)
// AccountsCmd manages accounts on Section
type AccountsCmd struct {
List AccountsListCmd `cmd help:"List accounts on Section." default:"1"`
}
// AccountsListCmd handles listing accounts on Section
type AccountsListCmd struct{}
// Run executes the command
func (c *AccountsListCmd) Run(cli *CLI, ctx *kong.Context,logWriters *LogWriters) (err error) {
s := NewSpinner("Looking up accounts", logWriters)
s.Start()
accounts, err := api.Accounts()
s.Stop()
if err != nil {
return err
}
table := NewTable(cli, os.Stdout)
table.SetHeader([]string{"Account ID", "Account Name"})
for _, a := range accounts {
r := []string{strconv.Itoa(a.ID), a.AccountName}
table.Append(r)
}
table.Render()
return err
}
// AccountsCreateCmd handles creating apps on Section
type AccountsCreateCmd struct{}