charmbracelet / gum

A tool for glamorous shell scripts 🎀
MIT License
17.37k stars 331 forks source link

`gum input` mangling prompt (docs need updated) #586

Open tj-smith47 opened 1 month ago

tj-smith47 commented 1 month ago

Describe the bug Previously functional gum input blocks in a script my company uses are now mangled - r

To Reproduce Consider the following block in a script:

#!/usr/bin/env bash

REPO_NAME=$(gum input --prompt "Enter the name (title case) of the repository to add a devcontainer files (e.g., Some API): ")
[[ -z "${REPO_NAME}" ]] && (echo "No repository name provided. Exiting."; exit 1)

The input received is correct if typed, but it's a poor user experience not being able to see text when typing in a field that isn't a password.

Expected behavior No random newlines, all prompt text shows, input visible as I type.

Screenshots Given the above excerpt from the script, this is the output (before it was on a single line, text was visible):

Screenshot 2024-05-20 at 17 32 24

Desktop (please complete the following information):

Additional context Nothing changed in the script since it last worked flawlessly, so it seems to be the recent upgrade to gum.

tj-smith47 commented 1 month ago

I just figured out setting --width resolves this - it seems unintentional to push the burden of counting the length of each line to the user when previously this wasn't necessary. If not, it was not listed in the changelog, and uses of --width were subtly added to examples rather than an obvious indication it's now required. Previously, pressing Ctrl+C during a gum choose did not print a unable to run confirm: user aborted message. This compromises the cleanliness of it's use in scripts. The changelog was posed as though there weren't any breaking changes (given that none were provided), but this has not been my experience.