feat(cli): support batch delete via variadic CIDs and --stdin - #1978
Merged
Conversation
Signed-off-by: Catarina Paralta <clouropa@cisco.com>
paralta
force-pushed
the
feat/delete-batch
branch
from
August 5, 2026 12:15
b72089a to
d912564
Compare
2 tasks
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR extends dirctl delete to support batch deletion by accepting multiple CIDs as positional arguments and by adding a --stdin mode that reads either a JSON array of CID strings or line-delimited CIDs. It also factors shared stdin/argument handling into a reusable cli/util/cids package and updates routing publish/unpublish to use it.
Changes:
- Add variadic CID support and
--stdiningestion todirctl delete, using a single streaming RPC (DeleteBatch) for batched deletes. - Introduce
cli/util/cidshelpers (args validation, stdin parsing, deduplication) and refactor routing publish/unpublish to reuse them. - Add end-to-end coverage for delete batch behaviors and update CLI reference documentation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/shared/utils/cli.go | Updates E2E CLI helper to support Delete(...cids) and DeleteFromStdin(...). |
| tests/e2e/local/17_delete_test.go | Adds E2E tests covering single delete, multi-arg delete, stdin JSON/lines, and validation errors. |
| docs/content/dir/dir-cli-reference.md | Documents variadic delete usage and the new --stdin flag + examples. |
| cli/util/cids/cids.go | New shared helpers for --stdin parsing, deduplication, and Cobra args validation. |
| cli/util/cids/cids_test.go | Unit tests for stdin parsing, deduplication, merging behavior, and args validation. |
| cli/cmd/routing/unpublish.go | Refactors to shared CID collection/validation and updates help text note. |
| cli/cmd/routing/publish.go | Refactors to shared CID collection/validation, removing duplicated stdin parsing code. |
| cli/cmd/delete/delete.go | Implements variadic CIDs, --stdin, and batch deletion via DeleteBatch, with output branching for single vs batch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
84
to
+89
| // Output in the appropriate format | ||
| return presenter.PrintMessage(cmd, "record", "Deleted record with CID", cid) | ||
| if len(cids) == 1 { | ||
| return presenter.PrintMessage(cmd, "record", "Deleted record with CID", cids[0]) | ||
| } | ||
|
|
||
| return presenter.PrintMessage(cmd, "records", "Deleted records with CIDs", cids) |
Comment on lines
+65
to
+68
| data, err := io.ReadAll(reader) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to read stdin: %w", err) | ||
| } |
Signed-off-by: Catarina Paralta <clouropa@cisco.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dirctl deleteaccepted exactly one CID even though the RPC is client-streaming and the SDK already exposesDeleteBatch, so cleanup workflows needed a shell loop spawning a process per record. Delete now takes variadic CIDs and a--stdinflag reading either a JSON array fromdirctl search --output jsonor line-delimited CIDs, sending the batch over a single stream.--output rawstill emits just the CID, since delete's help advertises that for scripting. Only batches get the new array shape.routing publish/unpublishmoved into a shared package instead of being copied a third time.sync create --stdinis left alone: same flag name, but it reads routing search responses for the peer multiaddrs a CID list can't provide.