writeAllFlags writes all flags with translated descriptions
()
| 218 | |
| 219 | // writeAllFlags writes all flags with translated descriptions |
| 220 | func (h *TranslatedHelpWriter) writeAllFlags() { |
| 221 | // Use direct reflection on the Flags struct to get all flag definitions |
| 222 | flagsType := reflect.TypeFor[Flags]() |
| 223 | |
| 224 | for field := range flagsType.Fields() { |
| 225 | shortTag := field.Tag.Get("short") |
| 226 | longTag := field.Tag.Get("long") |
| 227 | defaultTag := field.Tag.Get("default") |
| 228 | |
| 229 | if longTag == "" { |
| 230 | continue // Skip fields without long tags |
| 231 | } |
| 232 | |
| 233 | // Get translated description |
| 234 | description := h.getTranslatedDescription(longTag) |
| 235 | |
| 236 | // Format the flag line |
| 237 | var flagLine strings.Builder |
| 238 | flagLine.WriteString(" ") |
| 239 | |
| 240 | if shortTag != "" { |
| 241 | flagLine.WriteString(fmt.Sprintf("-%s, ", shortTag)) |
| 242 | } |
| 243 | |
| 244 | flagLine.WriteString(fmt.Sprintf("--%s", longTag)) |
| 245 | |
| 246 | // Add parameter indicator for non-boolean flags |
| 247 | isBoolFlag := field.Type.Kind() == reflect.Bool || |
| 248 | strings.HasSuffix(longTag, "patterns") || |
| 249 | strings.HasSuffix(longTag, "models") || |
| 250 | strings.HasSuffix(longTag, "contexts") || |
| 251 | strings.HasSuffix(longTag, "sessions") || |
| 252 | strings.HasSuffix(longTag, "extensions") || |
| 253 | strings.HasSuffix(longTag, "strategies") || |
| 254 | strings.HasSuffix(longTag, "vendors") || |
| 255 | strings.HasSuffix(longTag, "voices") || |
| 256 | longTag == "setup" || longTag == "stream" || longTag == "raw" || |
| 257 | longTag == "copy" || longTag == "updatepatterns" || |
| 258 | longTag == "output-session" || longTag == "changeDefaultModel" || |
| 259 | longTag == "playlist" || longTag == "transcript" || |
| 260 | longTag == "transcript-with-timestamps" || longTag == "comments" || |
| 261 | longTag == "metadata" || longTag == "readability" || |
| 262 | longTag == "input-has-vars" || longTag == "no-variable-replacement" || |
| 263 | longTag == "dry-run" || longTag == "serve" || longTag == "serveOllama" || |
| 264 | longTag == "version" || longTag == "shell-complete-list" || |
| 265 | longTag == "search" || longTag == "suppress-think" || |
| 266 | longTag == "disable-responses-api" || longTag == "split-media-file" || |
| 267 | longTag == "notification" |
| 268 | |
| 269 | if !isBoolFlag { |
| 270 | flagLine.WriteString("=") |
| 271 | } |
| 272 | |
| 273 | // Pad to align descriptions |
| 274 | flagStr := flagLine.String() |
| 275 | padding := max(34-len(flagStr), 2) |
| 276 | |
| 277 | fmt.Fprintf(h.writer, "%s%s%s", flagStr, strings.Repeat(" ", padding), description) |
no test coverage detected