parseAgentFlags extracts --agent and --agent-path from args[startIdx:], returning the agent name, agent path, remaining args (with agent flags removed), and the updated index offsets. It exits on missing values.
(args []string, startIdx int)
| 126 | // returning the agent name, agent path, remaining args (with agent flags removed), |
| 127 | // and the updated index offsets. It exits on missing values. |
| 128 | func parseAgentFlags(args []string, startIdx int) (agentName, agentPath string, remaining []string) { |
| 129 | for i := startIdx; i < len(args); i++ { |
| 130 | arg := args[i] |
| 131 | switch { |
| 132 | case arg == "--agent": |
| 133 | if i+1 < len(args) { |
| 134 | i++ |
| 135 | agentName = args[i] |
| 136 | } else { |
| 137 | fmt.Fprintf(os.Stderr, "Error: --agent requires a value (claude, codex, opencode, or cursor)\n") |
| 138 | os.Exit(1) |
| 139 | } |
| 140 | case strings.HasPrefix(arg, "--agent="): |
| 141 | agentName = strings.TrimPrefix(arg, "--agent=") |
| 142 | case arg == "--agent-path": |
| 143 | if i+1 < len(args) { |
| 144 | i++ |
| 145 | agentPath = args[i] |
| 146 | } else { |
| 147 | fmt.Fprintf(os.Stderr, "Error: --agent-path requires a value\n") |
| 148 | os.Exit(1) |
| 149 | } |
| 150 | case strings.HasPrefix(arg, "--agent-path="): |
| 151 | agentPath = strings.TrimPrefix(arg, "--agent-path=") |
| 152 | default: |
| 153 | remaining = append(remaining, arg) |
| 154 | } |
| 155 | } |
| 156 | return |
| 157 | } |
| 158 | |
| 159 | // parseTUIFlags parses command-line flags for TUI mode |
| 160 | func parseTUIFlags() *TUIOptions { |
no outgoing calls
no test coverage detected