{"record":{"id":"9092b26b2dcf44c1","repo":"JanDeDobbeleer/oh-my-posh","slug":"flag-q-does-not-exist","errorCode":null,"errorMessage":"flag %q does not exist","messagePattern":"flag %q does not exist","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmdflag/cmdflag.go","lineNumber":182,"sourceCode":"}\n\nfunc (f *FlagSet) ShorthandLookup(name string) *Flag {\n\tif name == \"\" {\n\t\treturn nil\n\t}\n\n\treturn f.shorthands[name[0]]\n}\n\nfunc (f *FlagSet) Changed(name string) bool {\n\tflag := f.flags[name]\n\treturn flag != nil && flag.Changed\n}\n\nfunc (f *FlagSet) MarkHidden(name string) error {\n\tflag := f.flags[name]\n\tif flag == nil {\n\t\treturn fmt.Errorf(\"flag %q does not exist\", name)\n\t}\n\n\tflag.Hidden = true\n\treturn nil\n}\n\n// VisitAll visits the flags in registration order rather than\n// lexicographically: the sole caller formats a command line and is\n// order-insensitive, and usage rendering sorts separately.\nfunc (f *FlagSet) VisitAll(fn func(*Flag)) {\n\tfor _, flag := range f.order {\n\t\tfn(flag)\n\t}\n}\n\n// AddFlagSet adds flags from another set that are not yet present.\nfunc (f *FlagSet) AddFlagSet(other *FlagSet) {\n\tif other == nil {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cmdflag/cmdflag.go#L164-L200","documentation":"FlagSet.MarkHidden looks up a flag by name in the set's internal map and marks it hidden from help output. If no flag with that name is registered, it returns this error quoting the requested name. It is a programmatic lookup failure, not a runtime user error.","triggerScenarios":"Calling MarkHidden(name) with a flag name that was never added via the FlagSet (typo, wrong casing, or the flag is registered on a different FlagSet/command).","commonSituations":"Renaming a flag but forgetting to update the MarkHidden call; attempting to hide an inherited/parent command's flag from a subcommand's FlagSet.","solutions":["Fix the name passed to MarkHidden to match the registered flag exactly","Ensure the flag is added (AddFlag/definition) before MarkHidden is called","Call MarkHidden on the FlagSet/command that actually owns the flag"],"exampleFix":"// before\nflags.MarkHidden(\"verboose\")\n// after\nflags.MarkHidden(\"verbose\")","handlingStrategy":"validation","validationCode":"if flags.Lookup(name) == nil {\n    return fmt.Errorf(\"flag %q does not exist\", name) // or skip hiding\n}\nreturn flags.MarkHidden(name)","typeGuard":null,"tryCatchPattern":"if err := flags.MarkHidden(\"verbose\"); err != nil {\n    // flag name typo or wrong FlagSet: fix the call, don't ignore at runtime\n}","preventionTips":["Extract flag names into constants shared between definition and MarkHidden calls","Hide a flag on the same FlagSet/command that registers it","Cover MarkHidden calls with a unit test so renames fail fast"],"tags":["cli","flags","developer-error"],"backgroundTag":"flag-not-found","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}