{"record":{"id":"d7539b7d1847e4aa","repo":"mislav/hub","slug":"s-s","errorCode":null,"errorMessage":"%s\n%s","messagePattern":"%s\n%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/commands.go","lineNumber":67,"sourceCode":"\ntype ErrHelp struct {\n\terr string\n}\n\nfunc (e ErrHelp) Error() string {\n\treturn e.err\n}\n\nfunc (c *Command) parseArguments(args *Args) error {\n\tknownFlags := c.KnownFlags\n\tif knownFlags == \"\" {\n\t\tknownFlags = c.Long\n\t}\n\targs.Flag = utils.NewArgsParserWithUsage(\"-h, --help\\n\" + knownFlags)\n\n\trest, err := args.Flag.Parse(args.Params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s\\n%s\", err, c.Synopsis())\n\t}\n\tif args.Flag.Bool(\"--help\") {\n\t\treturn &ErrHelp{err: c.Synopsis()}\n\t}\n\targs.Params = rest\n\targs.Terminator = args.Flag.HasTerminated\n\treturn nil\n}\n\nfunc (c *Command) Use(subCommand *Command) {\n\tif c.subCommands == nil {\n\t\tc.subCommands = make(map[string]*Command)\n\t}\n\tc.subCommands[subCommand.Name()] = subCommand\n\tsubCommand.parentCommand = c\n}\n\nfunc (c *Command) UsageError(msg string) error {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/commands.go#L49-L85","documentation":"In commands/commands.go parseArguments, the flag parser (args.Flag.Parse) fails on the supplied arguments (unknown flag, missing value, bad syntax). The returned error is wrapped with the command's synopsis so the user sees the parse error followed by usage text.","triggerScenarios":"Calling the command with an unrecognized flag, a flag missing its required value, malformed `--flag=value` syntax, or flags placed after a terminator, making args.Flag.Parse(args.Params) return a non-nil error.","commonSituations":"Typo in a flag name (`--recursion` vs `--recursive`); using a flag not supported by the installed hub version; passing flags after positional args when the parser doesn't allow it; scripting the CLI with quoting mistakes.","solutions":["Read the usage block printed after the error and correct the flag name/value.","Run the command with `-h/--help` to list valid flags.","If a flag seems valid but rejected, check your hub version (`hub version`) and upgrade."],"exampleFix":"// before\nhub pull-request --recurse-submodules   // flag parse error + usage\n// after\nhub pull-request --base master --message \"PR title\"","handlingStrategy":"validation","validationCode":"// validate args against the parser before invoking\nflags := utils.NewArgsParserWithUsage(\"-h, --help\\n\" + knownFlags)\nif _, err := flags.Parse(os.Args[1:]); err != nil {\n    fmt.Fprintln(os.Stderr, err)\n    os.Exit(2)\n}","typeGuard":null,"tryCatchPattern":"rest, err := args.Flag.Parse(args.Params)\nif err != nil {\n    fmt.Fprintf(os.Stderr, \"%s\\n%s\\n\", err, c.Synopsis())\n    os.Exit(1)\n}","preventionTips":["Run commands with --help to confirm flag names before use","Quote shell arguments containing spaces or special chars","Pin and keep hub updated so flag names match documentation"],"tags":["cli","flag-parsing","usage"],"backgroundTag":"invalid-command-line-flag","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}