Skip to content

fix(wsh): prevent deleteblock from silently ignoring positional arguments#3419

Open
Jason-Shen2 wants to merge 1 commit into
wavetermdev:mainfrom
Jason-Shen2:fix/wsh-deleteblock-block-arg
Open

fix(wsh): prevent deleteblock from silently ignoring positional arguments#3419
Jason-Shen2 wants to merge 1 commit into
wavetermdev:mainfrom
Jason-Shen2:fix/wsh-deleteblock-block-arg

Conversation

@Jason-Shen2

Copy link
Copy Markdown

Summary

Fixes #3417

The wsh deleteblock command had two issues:

  1. The Use string didn't document the -b flag, making it unclear how to specify which block to delete
  2. Without Args validation, positional arguments were silently ignored. When users passed a block ID as a positional argument (e.g. wsh deleteblock BLOCKID instead of wsh deleteblock -b BLOCKID), the argument was ignored and the command defaulted to deleting the current block ("this"), causing it to "close itself."

Changes

  • Updated Use string to deleteblock [-b {blockid|blocknum|this}] to document the -b flag (matching the focusblock command pattern)
  • Added Long description clarifying default behavior
  • Added Args: cobra.NoArgs to reject accidental positional arguments with a clear error instead of silently ignoring them

Testing

  • go build ./cmd/wsh/ compiles successfully
  • go vet ./cmd/wsh/... passes
  • Verified wsh deleteblock --help shows correct usage with -b flag documented
  • Verified wsh deleteblock BLOCKID (positional) now returns an error instead of silently deleting the current block

…ents

- Add Args: cobra.NoArgs to reject accidental positional block IDs
- Add proper Use/Long documentation for the -b flag
- Align with focusblock command pattern

When users passed a block ID as a positional argument (e.g. 'wsh deleteblock BLOCKID'
instead of 'wsh deleteblock -b BLOCKID'), the argument was silently ignored and
the command defaulted to deleting the current block. Adding Args validation
causes cobra to reject positional arguments with an error, and the improved
documentation clarifies the correct usage.

Fixes wavetermdev#3417
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b0cf50bf-c7b1-4b2f-a314-d26a6058297b

📥 Commits

Reviewing files that changed from the base of the PR and between c99022c and 7b0534f.

📒 Files selected for processing (1)
  • cmd/wsh/cmd/wshcmd-deleteblock.go

Walkthrough

This change updates the deleteblock CLI command's help metadata. The Use field now explicitly documents the -b argument with accepted forms (blockid, blocknum, this), and the Long description is expanded to explain that omitting -b defaults to deleting the current block.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Changes

File Change Summary
cmd/wsh/cmd/wshcmd-deleteblock.go Updated Use and Long fields of deleteBlockCmd to document -b argument syntax and default behavior

Related issues: None found.

Related PRs: None found.

Suggested labels: documentation

Suggested reviewers: None found.


🐰 A tiny hop, a help text spruced,
No logic changed, just words reduced—
"Use -b" now clear as day,
Default to "this" when none's in play.
A rabbit's edit, light and neat. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR only updates usage and help text; it does not implement the requested rejection of positional args or delete the specified block. Add Args: cobra.NoArgs and ensure deleteblock -b BLOCKID targets the provided block instead of defaulting to this.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: preventing deleteblock from ignoring positional arguments.
Description check ✅ Passed The description is clearly related to the changeset and explains the same deleteblock fix.
Out of Scope Changes check ✅ Passed No unrelated or clearly out-of-scope changes are indicated beyond the deleteblock command update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: wsh deleteblock -b <oref> ignores the positional arg (?) and deletes the current block

1 participant