{"record":{"id":"9d803eddb4972169","repo":"charmbracelet/gum","slug":"no-options-provided-see-gum-choose-help","errorCode":null,"errorMessage":"no options provided, see `gum choose --help`","messagePattern":"no options provided, see `gum choose --help`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"choose/command.go","lineNumber":28,"sourceCode":"\n\t\"charm.land/bubbles/v2/help\"\n\t\"charm.land/bubbles/v2/paginator\"\n\ttea \"charm.land/bubbletea/v2\"\n\t\"charm.land/gum/v2/internal/stdin\"\n\t\"charm.land/gum/v2/internal/timeout\"\n\t\"charm.land/gum/v2/internal/tty\"\n\t\"charm.land/gum/v2/style\"\n)\n\n// Run provides a shell script interface for choosing between different through\n// options.\nfunc (o Options) Run() error {\n\tinput, _ := stdin.Read(stdin.StripANSI(o.StripANSI))\n\tif len(o.Options) > 0 && len(o.Selected) == 0 {\n\t\to.Selected = strings.Split(input, o.InputDelimiter)\n\t} else if len(o.Options) == 0 {\n\t\tif input == \"\" {\n\t\t\treturn errors.New(\"no options provided, see `gum choose --help`\")\n\t\t}\n\t\to.Options = strings.Split(input, o.InputDelimiter)\n\t}\n\n\t// normalize options into a map\n\toptions := map[string]string{}\n\t// keep the labels in the user-provided order\n\tvar labels []string\n\tfor _, opt := range o.Options {\n\t\tif o.LabelDelimiter == \"\" {\n\t\t\toptions[opt] = opt\n\t\t\tcontinue\n\t\t}\n\t\tlabel, value, ok := strings.Cut(opt, o.LabelDelimiter)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"invalid option format: %q\", opt)\n\t\t}\n\t\tlabels = append(labels, label)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/choose/command.go#L10-L46","documentation":"gum choose builds its option list either from flags/arguments or from stdin. When neither source yields any options, Run returns this error telling the developer to consult `gum choose --help`. It exists to fail fast rather than render an empty picker.","triggerScenarios":"Options.Run() is called with len(o.Options)==0 and stdin read yields an empty string — i.e. no positional/flag options were given and stdin was empty or closed.","commonSituations":"Scripting `gum choose` in a pipeline where the upstream command produced no output; piping an empty variable (e.g. `echo \"$EMPTY\" | gum choose`); forgetting that stdin is consumed only when no options are passed.","solutions":["Pass options as arguments: gum choose \"a\" \"b\" \"c\"","Pipe non-empty input into gum choose, e.g. `printf 'a\\nb\\n' | gum choose`","Verify the upstream command producing the piped list actually emits data before invoking gum choose"],"exampleFix":"// before\nprintf '' | gum choose  # error: no options provided\n// after\nprintf 'apple\\nbanana\\n' | gum choose","handlingStrategy":"validation","validationCode":"input=$(some_command)\n[ -n \"$input\" ] && printf '%s\\n' \"$input\" | gum choose || echo 'no options available'","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Check the piped input is non-empty before invoking gum choose","Always pass explicit options when scripting non-interactively","Remember gum choose reads stdin only when no options are given"],"tags":["cli","gum","choose","empty-input"],"backgroundTag":"empty-input-no-options","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}