2021-12-10 16:29:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-12-30 07:58:58 +00:00
|
|
|
"context"
|
|
|
|
|
2021-12-10 16:29:02 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2021-12-22 15:41:33 +00:00
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(accountsCmd)
|
|
|
|
}
|
|
|
|
|
2021-12-10 16:29:02 +00:00
|
|
|
var accountsCmd = &cobra.Command{
|
|
|
|
Use: "accounts",
|
|
|
|
|
|
|
|
// SilenceUsage is an option to silence usage when an error occurs.
|
|
|
|
SilenceUsage: true,
|
|
|
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2021-12-10 16:34:49 +00:00
|
|
|
if len(args) > 0 {
|
2021-12-31 18:04:20 +00:00
|
|
|
req := client.AccountService.NewGetAccountRequest(args[0])
|
|
|
|
account, err := req.Do(context.Background())
|
2021-12-10 16:34:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
logrus.Infof("account: %+v", account)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-12-31 18:04:20 +00:00
|
|
|
req := client.AccountService.NewListAccountsRequest()
|
|
|
|
accounts, err := req.Do(context.Background())
|
2021-12-10 16:29:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
logrus.Infof("accounts: %+v", accounts)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
2021-12-10 16:34:49 +00:00
|
|
|
|