{"record":{"id":"f2d5e73fdb0714d6","repo":"kovidgoyal/kitty","slug":"usage-atexit","errorCode":null,"errorMessage":"Usage: __atexit__","messagePattern":"Usage: __atexit__","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"tools/cmd/atexit/main.go","lineNumber":95,"sourceCode":"\t}\n\treturn\n}\n\nfunc EntryPoint(root *cli.Command) {\n\troot.AddSubCommand(&cli.Command{\n\t\tName:            \"__atexit__\",\n\t\tHidden:          true,\n\t\tOnlyArgsAllowed: true,\n\t\tRun: func(cmd *cli.Command, args []string) (rc int, err error) {\n\t\t\tif len(args) != 0 {\n\t\t\t\tif args[0] == \"test\" {\n\t\t\t\t\trc = 0\n\t\t\t\t\tif err = do_test(); err != nil {\n\t\t\t\t\t\trc = 1\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\treturn 1, fmt.Errorf(\"Usage: __atexit__\")\n\t\t\t}\n\t\t\treturn main()\n\t\t},\n\t})\n}\n","sourceCodeStart":77,"sourceCodeEnd":101,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cmd/atexit/main.go#L77-L101","documentation":"The atexit tool was invoked with unexpected command-line arguments: its CLI wrapper recognized no valid subcommand/flag combination, so it bails with the usage message 'Usage: __atexit__'. It is a pure argument-validation error — nothing ran yet.","triggerScenarios":"Running the atexit binary with arguments that don't match any registered subcommand (e.g. a typo'd or unsupported first argument), so argument parsing falls through to the usage-error return in main.go:95.","commonSituations":"Typos in subcommand names, passing flags before/without the subcommand, scripts written against an older version whose subcommands were renamed, or copy-pasting an invocation from docs of a different tool.","solutions":["Run the tool with no arguments or --help to list valid subcommands","Fix the typo/order of the first argument to a registered subcommand","If a script breaks after an upgrade, diff the tool's help output against what the script passes"],"exampleFix":"# before\n__atexit__ testt\n# after\n__atexit__ test","handlingStrategy":"validation","validationCode":"// Validate argv before invoking the tool\nvalid := map[string]bool{\"test\": true /* other real subcommands */}\nif len(os.Args) > 1 && !valid[os.Args[1]] {\n    fmt.Fprintln(os.Stderr, \"Usage: __atexit__\"); os.Exit(2)\n}","typeGuard":null,"tryCatchPattern":"// Shell wrapper\nif ! __atexit__ \"$cmd\" 2>/dev/null; then\n    echo \"unknown subcommand: $cmd\" >&2; __atexit__ --help\nfi","preventionTips":["Script against --help output or a pinned version","Add a smoke test that exercises each scripted subcommand after upgrades"],"tags":["cli","usage","argument-validation","go"],"backgroundTag":"invalid-command-usage","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}