cmd/sync: support multiple session names

This commit is contained in:
c9s 2022-06-01 18:29:18 +08:00
parent 1a85e62993
commit 991d13cb32
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -12,7 +12,7 @@ import (
) )
func init() { func init() {
SyncCmd.Flags().String("session", "", "the exchange session name for sync") SyncCmd.Flags().StringArray("session", []string{}, "the exchange session name for sync")
SyncCmd.Flags().String("symbol", "", "symbol of market for syncing") SyncCmd.Flags().String("symbol", "", "symbol of market for syncing")
SyncCmd.Flags().String("since", "", "sync from time") SyncCmd.Flags().String("since", "", "sync from time")
RootCmd.AddCommand(SyncCmd) RootCmd.AddCommand(SyncCmd)
@ -57,7 +57,7 @@ var SyncCmd = &cobra.Command{
return err return err
} }
sessionName, err := cmd.Flags().GetString("session") sessionNames, err := cmd.Flags().GetStringArray("session")
if err != nil { if err != nil {
return err return err
} }
@ -93,9 +93,9 @@ var SyncCmd = &cobra.Command{
} }
} }
if len(sessionName) > 0 { if len(sessionNames) > 0 {
if userConfig.Sync != nil && len(userConfig.Sync.Sessions) > 0 { if userConfig.Sync != nil && len(userConfig.Sync.Sessions) > 0 {
userConfig.Sync.Sessions = []string{sessionName} userConfig.Sync.Sessions = sessionNames
} }
} }