opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Named arguments for command parsed from `$ARGUMENTS`

Open fmatsos opened this issue 4 months ago • 7 comments

I thought about a better DX around $ARGUMENTS in commands, and saw a PR started for that: #2199 But I think we can improve much more the DX by using named arguments, thanks to frontmatter.

$ARGUMENTS will be parsed if an arguments key exists, assign values to each array value based on their array position.

I thought about something like that:

---
description: My command with arguments
arguments:
  - lorem
  - ipsum
  - ...
---

Show to user the argument 1: $LOREM

`! echo $IPSUM`

arguments values indicate the arguments names, and their position on which index of $ARGUMENTS retrieve the value. In the example $LOREM will be value of $ARGUMENTS[0], $IPSUM value of $ARGUMENTS[1], etc.

Imho it will help to have prompts of commands more understandable.

fmatsos avatar Aug 24 '25 18:08 fmatsos