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