mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
add --session option check
This commit is contained in:
parent
7c57246070
commit
1a81813e17
|
@ -33,6 +33,15 @@ var accountCmd = &cobra.Command{
|
|||
return errors.New("--config option is required")
|
||||
}
|
||||
|
||||
sessionName, err := cmd.Flags().GetString("session")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(sessionName) == 0 {
|
||||
return errors.New("--session option is required")
|
||||
}
|
||||
|
||||
var userConfig *bbgo.Config
|
||||
if _, err := os.Stat(configFile); err == nil {
|
||||
// load successfully
|
||||
|
@ -57,11 +66,6 @@ var accountCmd = &cobra.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
sessionName, err := cmd.Flags().GetString("session")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
session, ok := environ.Session(sessionName)
|
||||
if !ok {
|
||||
return fmt.Errorf("session %s not found", sessionName)
|
||||
|
|
|
@ -24,6 +24,7 @@ var balancesCmd = &cobra.Command{
|
|||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
|
||||
configFile, err := cmd.Flags().GetString("config")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -33,6 +34,15 @@ var balancesCmd = &cobra.Command{
|
|||
return errors.New("--config option is required")
|
||||
}
|
||||
|
||||
sessionName, err := cmd.Flags().GetString("session")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(sessionName) == 0 {
|
||||
return errors.New("--session option is required")
|
||||
}
|
||||
|
||||
// if config file exists, use the config loaded from the config file.
|
||||
// otherwise, use a empty config object
|
||||
var userConfig *bbgo.Config
|
||||
|
@ -56,10 +66,6 @@ var balancesCmd = &cobra.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
sessionName, err := cmd.Flags().GetString("session")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
session, ok := environ.Session(sessionName)
|
||||
if !ok {
|
||||
|
|
Loading…
Reference in New Issue
Block a user