kucoin: split cmd to files

This commit is contained in:
c9s 2021-12-11 00:29:02 +08:00
parent 6161a6a292
commit 76f122d998
3 changed files with 47 additions and 35 deletions

View File

@ -0,0 +1,23 @@
package main
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
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 {
accounts, err := client.AccountService.QueryAccounts()
if err != nil {
return err
}
logrus.Infof("accounts: %+v", accounts)
return nil
},
}

View File

@ -21,41 +21,6 @@ func init() {
rootCmd.AddCommand(subAccountsCmd)
}
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 {
accounts, err := client.AccountService.QueryAccounts()
if err != nil {
return err
}
log.Infof("accounts: %+v", accounts)
return nil
},
}
var subAccountsCmd = &cobra.Command{
Use: "subaccounts",
Short: "subaccounts",
// SilenceUsage is an option to silence usage when an error occurs.
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
subAccounts, err := client.AccountService.QuerySubAccounts()
if err != nil {
return err
}
log.Infof("subAccounts: %+v", subAccounts)
return nil
},
}
var rootCmd = &cobra.Command{
Use: "kucoin",
Short: "kucoin",

View File

@ -0,0 +1,24 @@
package main
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var subAccountsCmd = &cobra.Command{
Use: "subaccounts",
Short: "subaccounts",
// SilenceUsage is an option to silence usage when an error occurs.
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
subAccounts, err := client.AccountService.QuerySubAccounts()
if err != nil {
return err
}
logrus.Infof("subAccounts: %+v", subAccounts)
return nil
},
}