diff --git a/cli/p2p_collection_add.go b/cli/p2p_collection_add.go index 3cc3eb3dad..86e0d8f6f9 100644 --- a/cli/p2p_collection_add.go +++ b/cli/p2p_collection_add.go @@ -32,7 +32,16 @@ Example: add multiple collections Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { store := mustGetStoreContext(cmd) - collectionIDs := strings.Split(args[0], ",") + + var collectionIDs []string + for _, id := range strings.Split(args[0], ",") { + id = strings.TrimSpace(id) + if id == "" { + continue + } + collectionIDs = append(collectionIDs, id) + } + return store.AddP2PCollections(cmd.Context(), collectionIDs) }, } diff --git a/cli/p2p_collection_remove.go b/cli/p2p_collection_remove.go index b62867a7e6..0c4d14effd 100644 --- a/cli/p2p_collection_remove.go +++ b/cli/p2p_collection_remove.go @@ -32,7 +32,16 @@ Example: remove multiple collections Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { store := mustGetStoreContext(cmd) - collectionIDs := strings.Split(args[0], ",") + + var collectionIDs []string + for _, id := range strings.Split(args[0], ",") { + id = strings.TrimSpace(id) + if id == "" { + continue + } + collectionIDs = append(collectionIDs, id) + } + return store.RemoveP2PCollections(cmd.Context(), collectionIDs) }, }