Skip to content

fix(wsh): accept block reference as positional arg for deleteblock#3430

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

fix(wsh): accept block reference as positional arg for deleteblock#3430
Jason-Shen2 wants to merge 1 commit into
wavetermdev:mainfrom
Jason-Shen2:fix/wsh-deleteblock-positional-arg

Conversation

@Jason-Shen2

Copy link
Copy Markdown

Summary

The wsh deleteblock command previously only accepted a block reference via the --block/-b flag, with no Args validation, causing user confusion when positional arguments were silently ignored and the current block was deleted instead.

Changes

  • Accept an optional positional block-ref argument (e.g. wsh deleteblock 2)
  • Add Args: cobra.MaximumNArgs(1) to validate argument count
  • Add Long description documenting accepted reference formats (block:oid, uuid, block number, keywords like 'this')
  • Add resolveBlockArgWithOverride() helper that prefers positional arg over --block/-b flag, defaulting to 'this' when neither is specified
  • Update Use string to show the optional [block-ref] argument

Usage

# Delete current block (default)
wsh deleteblock

# Delete block by number (1-indexed in current tab)
wsh deleteblock 2

# Delete block by full ORef
wsh deleteblock block:abc123-def456

# Delete block using -b flag (still supported)
wsh deleteblock -b 2

Fixes #3417

The 'wsh deleteblock' command previously only accepted a block reference
via the --block/-b flag, with no Args validation, causing user confusion
when positional arguments were silently ignored and the current block was
deleted instead. This also addresses issue wavetermdev#3417 where using -b BLOCKID
appeared to delete the wrong block due to the unclear command interface.

Changes:
- Accept an optional positional block-ref argument (e.g. 'wsh deleteblock 2')
- Add Args: cobra.MaximumNArgs(1) to validate argument count
- Add Long description documenting accepted formats (block:oid, uuid,
  block number, keywords like 'this')
- Add resolveBlockArgWithOverride() helper that prefers positional arg
  over --block/-b flag, defaulting to 'this' when neither is specified
- Update Use string to show the optional argument

Fixes wavetermdev#3417
@coderabbitai

coderabbitai Bot commented Jul 13, 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: 2bc2762b-fbd8-4763-b44c-269dbb3bfe94

📥 Commits

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

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

Walkthrough

The deleteblock command now accepts an optional positional block reference, limits input to one argument, and documents supported reference formats and default behavior. Runtime resolution prioritizes the positional argument, then the configured block argument, and finally the current block. Resolution uses resolveSimpleId with wrapped errors for failures.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: accepting a positional block reference for deleteblock.
Description check ✅ Passed The description accurately describes the deleteblock argument handling and helper changes in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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