Skip to content

Commit

Permalink
fix for cli adding or removing empty p2p collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Oct 6, 2023
1 parent 0d3f6be commit 9220ac4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion cli/p2p_collection_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
Expand Down
11 changes: 10 additions & 1 deletion cli/p2p_collection_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
Expand Down

0 comments on commit 9220ac4

Please sign in to comment.