mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
43 lines
777 B
Go
43 lines
777 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(accountsCmd)
|
|
}
|
|
|
|
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 {
|
|
if len(args) > 0 {
|
|
req := client.AccountService.NewGetAccountRequest(args[0])
|
|
account, err := req.Do(context.Background())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
logrus.Infof("account: %+v", account)
|
|
return nil
|
|
}
|
|
|
|
req := client.AccountService.NewListAccountsRequest()
|
|
accounts, err := req.Do(context.Background())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
logrus.Infof("accounts: %+v", accounts)
|
|
return nil
|
|
},
|
|
}
|
|
|