You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/slashcommand/README.md
+49-26Lines changed: 49 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,21 @@ Package `slashcommand` provides a parser for slash commands commonly used in AI
4
4
5
5
## Overview
6
6
7
-
This package parses slash commands using bash-like argument parsing:
7
+
This package parses slash commands using bash-like argument parsing. The parser can find slash commands anywhere in the input text, not just at the beginning:
8
8
```
9
9
/task-name arg1 "arg 2" arg3
10
10
```
11
11
12
12
The parser extracts:
13
13
-**Task name**: The command identifier (without the leading `/`)
14
14
-**Arguments**: Positional arguments accessed via `$ARGUMENTS`, `$1`, `$2`, `$3`, etc.
15
+
-**Found status**: Boolean indicating whether a slash command was found
15
16
16
17
Arguments are parsed like bash:
17
18
- Quoted arguments (single or double quotes) can contain spaces
18
19
- Quotes are removed from parsed arguments
19
20
- Escape sequences are supported in double quotes (`\"`)
21
+
- Arguments are extracted until end of line
20
22
21
23
## Installation
22
24
@@ -30,19 +32,34 @@ go get github.com/kitproj/coding-context-cli/pkg/slashcommand
Text /deploy prod\nNext line # Arguments stop at newline: task = "deploy", $1 = "prod"
77
99
```
78
100
79
-
### Invalid Examples
101
+
### Cases with No Command Found
80
102
```
81
-
fix-bug # Missing leading /
82
-
/ # Empty command
83
-
/fix-bug "unclosed # Unclosed quote
103
+
fix-bug # Missing leading /: found = false
104
+
No command here # No slash: found = false
84
105
```
85
106
86
107
## Error Handling
87
108
88
-
The parser returns descriptive errors for invalid commands:
109
+
The parser returns errors only for malformed commands (e.g., unclosed quotes). If no slash command is found, the function returns `found=false` without an error.
0 commit comments