{"record":{"id":"8279c5408a788dc2","repo":"charmbracelet/gum","slug":"at-least-one-between-file-and-directory-must-b","errorCode":null,"errorMessage":"at least one between --file and --directory must be set","messagePattern":"at least one between --file and --directory must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"file/command.go","lineNumber":19,"sourceCode":"package file\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"charm.land/bubbles/v2/filepicker\"\n\t\"charm.land/bubbles/v2/help\"\n\ttea \"charm.land/bubbletea/v2\"\n\t\"charm.land/gum/v2/internal/timeout\"\n\t\"charm.land/gum/v2/style\"\n)\n\n// Run is the interface to picking a file.\nfunc (o Options) Run() error {\n\tif !o.File && !o.Directory {\n\t\treturn errors.New(\"at least one between --file and --directory must be set\")\n\t}\n\n\tif o.Path == \"\" {\n\t\to.Path = \".\"\n\t}\n\n\tpath, err := filepath.Abs(o.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"file not found: %w\", err)\n\t}\n\n\tfp := filepicker.New()\n\tfp.CurrentDirectory = path\n\tfp.Path = path\n\tfp.SetHeight(o.Height)\n\tfp.AutoHeight = o.Height == 0\n\tfp.Cursor = o.Cursor\n\tfp.DirAllowed = o.Directory","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/file/command.go#L1-L37","documentation":"gum file requires the caller to enable at least one selection mode: --file and/or --directory. With both false there is nothing the picker is allowed to select, so Run rejects the invocation immediately.","triggerScenarios":"Options.Run() is invoked with o.File == false && o.Directory == false — the gum file command constructed programmatically (or via flags) without either mode flag set.","commonSituations":"Building gum.Options in Go and forgetting to set File or Directory fields; stripping flags when wrapping gum in a script; version changes where defaults shifted.","solutions":["Pass --file, --directory, or both when invoking gum file","Set File: true (or Directory: true) on the Options struct before calling Run","Update wrapper scripts to forward the mode flags"],"exampleFix":"// before\ngum file  # error\n// after\ngum file --file\n// Go\n// before: gum.FileOptions{}\n// after:  gum.FileOptions{File: true}","handlingStrategy":"validation","validationCode":"null","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --file and/or --directory to gum file","In Go set File or Directory on the Options struct before Run","Audit wrapper scripts for dropped flags"],"tags":["cli","gum","file","flags"],"backgroundTag":"required-flag-missing","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}