Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSlashCommand ¶
ParseSlashCommand parses a slash command string and extracts the task name and parameters. The expected format is: /task-name arg1 "arg 2" arg3
Arguments are parsed like Bash:
- Quoted arguments can contain spaces
- Both single and double quotes are supported
- Quotes are removed from the parsed arguments
Examples:
- "/fix-bug 123" -> taskName: "fix-bug", params: {"ARGUMENTS": "123", "1": "123"}
- "/code-review \"PR #42\" high" -> taskName: "code-review", params: {"ARGUMENTS": "\"PR #42\" high", "1": "PR #42", "2": "high"}
Returns:
- taskName: the task name (without the leading slash)
- params: a map containing:
- "ARGUMENTS": the full argument string (with quotes preserved)
- "1", "2", "3", etc.: positional arguments (with quotes removed)
- err: an error if the command format is invalid
Example ¶
package main
import (
"fmt"
"github.com/kitproj/coding-context-cli/pkg/slashcommand"
)
func main() {
// Parse a simple command without parameters
taskName, params, err := slashcommand.ParseSlashCommand("/fix-bug")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Task: %s, Params: %v\n", taskName, params)
// Parse a command with single argument
taskName, params, err = slashcommand.ParseSlashCommand("/fix-bug 123")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Task: %s, $1: %s\n", taskName, params["1"])
// Parse a command with multiple arguments
taskName, params, err = slashcommand.ParseSlashCommand(`/implement-feature "User Login" high`)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Task: %s, $1: %s, $2: %s\n", taskName, params["1"], params["2"])
}
Output: Task: fix-bug, Params: map[] Task: fix-bug, $1: 123 Task: implement-feature, $1: User Login, $2: high
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.