{"record":{"id":"a0b6ae0cb2f05528","repo":"kovidgoyal/kitty","slug":"must-specify-at-most-one-output-file","errorCode":null,"errorMessage":"Must specify at most one output file","messagePattern":"Must specify at most one output file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/cmd/at/screenshot.go","lineNumber":25,"sourceCode":"\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/emmansun/base64\"\n\t\"github.com/kovidgoyal/kitty/tools/utils\"\n)\n\nfunc screenshot_handle_response(data []byte) error {\n\tpng_data, err := base64.StdEncoding.DecodeString(string(data))\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = os.Stdout.Write(png_data)\n\treturn err\n}\n\nfunc read_screenshot_args(io_data *rc_io_data, args []string) (func(io_data *rc_io_data) (bool, error), error) {\n\tif len(args) > 1 {\n\t\treturn nil, fmt.Errorf(\"%s\", \"Must specify at most one output file\")\n\t}\n\tif len(args) == 0 {\n\t\t// kitty writes the screenshot directly to the output file when one is\n\t\t// given (it runs on the same computer as kitty), so a custom response\n\t\t// handler is only needed to write the PNG data to STDOUT.\n\t\tio_data.handle_response = screenshot_handle_response\n\t}\n\treturn func(io_data *rc_io_data) (bool, error) {\n\t\t// io_data.rc.Payload is only populated after this generator is created,\n\t\t// so the payload field must be set here rather than above.\n\t\tif len(args) == 1 {\n\t\t\tpath, err := filepath.Abs(utils.Expanduser(args[0]))\n\t\t\tif err != nil {\n\t\t\t\treturn false, fmt.Errorf(\"%s is not a valid path with error: %w\", args[0], err)\n\t\t\t}\n\t\t\tset_payload_string_field(io_data, \"Output_path\", path)\n\t\t}\n\t\treturn true, nil","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cmd/at/screenshot.go#L7-L43","documentation":"kitty @ screenshot accepts at most one positional argument (an output file path). More than one file was given on the command line, which is rejected before the request is sent.","triggerScenarios":"Running e.g. 'kitty @ screenshot a.png b.png' — len(args) > 1 in read_screenshot_args.","commonSituations":"Users trying to screenshot multiple windows by listing files, or shell glob expansion producing several paths.","solutions":["Pass zero arguments to write PNG to stdout, or exactly one output path","To capture multiple windows, invoke the command once per window using --match","Quote arguments so globs don't expand unexpectedly"],"exampleFix":"# before\nkitty @ screenshot win1.png win2.png\n# after\nkitty @ screenshot --match id:1 win1.png && kitty @ screenshot --match id:2 win2.png","handlingStrategy":"validation","validationCode":"if len(args) > 1 { return errors.New(\"Must specify at most one output file\") }","typeGuard":"func validScreenshotArgs(args []string) bool { return len(args) <= 1 }","tryCatchPattern":null,"preventionTips":["Pass at most one output path","Loop with --match to capture multiple windows"],"tags":["kitty","remote-control","cli","screenshot"],"backgroundTag":"too-many-arguments","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}