[PR #2199] feat: implement $ARGUMENTS indexing and splitting for /commands #10231

Closed
opened 2026-02-16 18:14:51 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/2199

State: closed
Merged: No


Summary

This PR adds powerful new argument handling capabilities for custom commands, making them more flexible for complex workflows.

New Features

Argument Patterns:

  • $ARGUMENTS[n] - Single argument at index n
  • $ARGUMENTS[n*] - All arguments from index n onwards
  • $ARGUMENTS[n+] - Arguments at index n and n+1
  • $ARGUMENTS[n++] - Arguments at index n, n+1, and n+2
  • $ARGUMENTS[n:m] - Range from index n to m

Example

With "/hello hello world foo bar baz . -y"

$ARGUMENTS[0] → "hello"
$ARGUMENTS[1*] → "world foo bar baz . -y"
$ARGUMENTS[2+] → "foo bar"
$ARGUMENTS[3++] → "bar baz ."
$ARGUMENTS[1:4] → "world foo bar baz"

The implementation handles out-of-bounds indices gracefully

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/2199 **State:** closed **Merged:** No --- ## Summary This PR adds powerful new argument handling capabilities for custom commands, making them more flexible for complex workflows. ### New Features Argument Patterns: - `$ARGUMENTS[n]` - Single argument at index n - `$ARGUMENTS[n*]` - All arguments from index n onwards - `$ARGUMENTS[n+]` - Arguments at index n and n+1 - `$ARGUMENTS[n++]` - Arguments at index n, n+1, and n+2 - `$ARGUMENTS[n:m]` - Range from index n to m #### Example With "/hello hello world foo bar baz . -y" $ARGUMENTS[0] → "hello" $ARGUMENTS[1*] → "world foo bar baz . -y" $ARGUMENTS[2+] → "foo bar" $ARGUMENTS[3++] → "bar baz ." $ARGUMENTS[1:4] → "world foo bar baz" The implementation handles out-of-bounds indices gracefully
yindo added the pull-request label 2026-02-16 18:14:51 -05:00
yindo closed this issue 2026-02-16 18:14:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10231