-
Notifications
You must be signed in to change notification settings - Fork 1
Add named parameter support to slash commands #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Extended slash command parsing to support named parameters in key="value" format
alongside existing positional parameters. Named parameters can be mixed with
positional arguments and do not count toward positional numbering.
Examples:
- /fix-bug issue="PROJ-123" -> ${issue} = "PROJ-123"
- /task arg1 key="value" arg2 -> ${1}="arg1", ${2}="arg2", ${key}="value"
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
There was a problem hiding this comment.
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 adds named parameter support to slash commands, allowing users to specify parameters using key="value" syntax in addition to existing positional parameters. The implementation extends the argument parsing logic to detect and extract named parameters while maintaining backward compatibility with positional arguments.
Key Changes
- Added
parseBashArgsWithNamedfunction to parse both positional and named parameters from argument strings - Added
parseNamedParamhelper to identify arguments inkey=valueformat - Extended test coverage with 8 new test cases covering various named parameter scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
pkg/codingcontext/slashcommand.go |
Implemented named parameter parsing logic with parseBashArgsWithNamed and parseNamedParam functions; updated documentation comments to describe new syntax |
pkg/codingcontext/slashcommand_test.go |
Added comprehensive test cases for named parameters including spaces in values, escaped quotes, mixed usage with positional args, and special characters |
docs/reference/cli.md |
Documented named parameter syntax with examples showing usage patterns and equivalents to manual -p flag usage |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
@copilot positional arguments should retain their numbering: lts in:
|
|
@copilot make quotes mandatory. You can extract the same parser we used for |
Updated slash command parsing so that named parameters (key="value") are also
included as positional arguments in their original form. This addresses the
feedback that `/task arg1 issue="PROJ-123" arg2` should result in:
- ${1} = arg1
- ${2} = issue="PROJ-123"
- ${3} = arg2
- ${issue} = PROJ-123
Also added protections:
- Reserved key ARGUMENTS cannot be used as a named parameter key
- Numeric keys (1, 2, etc.) cannot be used as named parameter keys
- Duplicate named parameter keys: last value wins (documented behavior)
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
... Fixed in ee87d79. Named parameters now count toward positional numbering.
Also added protections for reserved keys (ARGUMENTS, numeric keys). |
Per @alexec's feedback, named parameters now require mandatory double quotes. - Unquoted values like `key=value` are treated as positional arguments - Single-quoted values like `key='value'` are also treated as positional arguments - Only `key="value"` format is recognized as a named parameter Updated parseNamedParamWithQuotes to validate double quote requirement. Added tests for unquoted and single-quoted edge cases. Updated documentation to clarify mandatory double quotes. Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Replaced manual character-by-character numeric check with strconv.Atoi for cleaner, more idiomatic Go code. Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Changed return type from ([]string, map[string]string, error) to
(map[string]string, error). The map now contains both positional keys
("1", "2", "3", etc.) and named parameter keys, eliminating the need
for a separate allArgs slice.
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot don't worry about protecting numeric arguments or ARGUMENTS. A user would have to misuse the system greatly for this to happen. |
Per @alexec's feedback, removed the validation that prevented named parameters from using ARGUMENTS or numeric keys. Users would have to misuse the system greatly for this to cause problems. Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.