Skip to content

feat(cli): support batch delete via variadic CIDs and --stdin - #1978

Merged
paralta merged 2 commits into
mainfrom
feat/delete-batch
Aug 5, 2026
Merged

feat(cli): support batch delete via variadic CIDs and --stdin#1978
paralta merged 2 commits into
mainfrom
feat/delete-batch

Conversation

@paralta

@paralta paralta commented Aug 5, 2026

Copy link
Copy Markdown
Member

dirctl delete accepted exactly one CID even though the RPC is client-streaming and the SDK already exposes DeleteBatch, so cleanup workflows needed a shell loop spawning a process per record. Delete now takes variadic CIDs and a --stdin flag reading either a JSON array from dirctl search --output json or line-delimited CIDs, sending the batch over a single stream.

  • Single-CID output is unchanged — --output raw still emits just the CID, since delete's help advertises that for scripting. Only batches get the new array shape.
  • Stdin parsing, deduplication, and argument validation shared with routing publish/unpublish moved into a shared package instead of being copied a third time.
  • sync create --stdin is left alone: same flag name, but it reads routing search responses for the peer multiaddrs a CID list can't provide.

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Aug 5, 2026
@paralta
paralta requested a review from akijakya August 5, 2026 12:14
Signed-off-by: Catarina Paralta <clouropa@cisco.com>
@paralta
paralta force-pushed the feat/delete-batch branch from b72089a to d912564 Compare August 5, 2026 12:15
@paralta paralta linked an issue Aug 5, 2026 that may be closed by this pull request
2 tasks
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.72222% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/util/cids/cids.go 88.0% 3 Missing and 3 partials ⚠️
cli/cmd/routing/publish.go 60.0% 1 Missing and 1 partial ⚠️
cli/cmd/routing/unpublish.go 60.0% 1 Missing and 1 partial ⚠️
cli/cmd/delete/delete.go 91.7% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@paralta
paralta marked this pull request as ready for review August 5, 2026 12:45
@paralta
paralta requested a review from a team as a code owner August 5, 2026 12:45
@akijakya
akijakya requested a lite review from Copilot August 5, 2026 13:06

@akijakya akijakya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --stdin ingestion to dirctl delete, using a single streaming RPC (DeleteBatch) for batched deletes.
  • Introduce cli/util/cids helpers (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 thread cli/util/cids/cids.go Outdated
Comment thread cli/cmd/delete/delete.go
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 thread cli/util/cids/cids.go
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>
@paralta
paralta merged commit a37aba3 into main Aug 5, 2026
35 checks passed
@paralta
paralta deleted the feat/delete-batch branch August 5, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support batch delete via variadic CIDs and --stdin

3 participants