Documentation
¶
Overview ¶
Package cliflags rewrites argv before cobra parses it, absorbing two common slips an LLM makes when generating a command line:
- camelCase / snake_case flag names — `--userId` / `--user_name` instead of the canonical kebab-case `--user-id` / `--user-name`;
- a flag stuck to its value — `--limit100` instead of `--limit 100`.
A rewrite happens ONLY when the result is a flag the command tree actually defines (and, for the sticky split, an integer-typed one), so unknown tokens pass through untouched and still surface cobra's normal "unknown flag" error. Every rewrite is reported as a Correction so the caller can echo it back — fixing the call and teaching the canonical form in one go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Correction ¶
type Correction struct {
Original string `json:"original"`
Corrected string `json:"corrected"`
Kind string `json:"kind"` // "flag-name" | "sticky-value"
}
Correction records one argv rewrite, for echoing back to the user/agent.
func Normalize ¶
func Normalize(args []string, info FlagInfo) (out []string, corrections []Correction)
Normalize rewrites args (argv without the program name) per the package doc. It returns the rewritten args and the list of corrections applied. Tokens after the `--` end-of-flags marker, short flags, and unknown long flags are left untouched.
type FlagInfo ¶
FlagInfo is the set of flags known to the command tree. Known holds every kebab-case flag name; Numeric is the subset whose value is integer/float typed (the only flags eligible for the sticky-value split).