You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to check if the following idea warrants a PR.
Working with claude-code, I got used to just selecting the number of an option when being offered choices (i.e. no need for Return). This made the current behaviour of e.g. bundle show <ambiguous name> stand out as added friction,
as Return is currently always needed.
Current behaviour
When a name matches more than one gem, bundle show/info/open print a numbered menu (via Bundler::CLI::Common#ask_for_spec_from) and read a whole line:
Accept the choice on a single keypress as soon as it's unambiguous, i.e. when no larger option number has the typed digits as a prefix:
≤ 9 options → any digit selects immediately, no Return.
≥ 10 options → only digits that are a prefix of a larger number wait (e.g. 1 when 10/11 exist); everything else (2–9, 0) still fires instantly. Return resolves the prefix to what's typed so far (e.g.
selecting 1 while 10 exists). Backspace edits, Ctrl-C aborts.
It's a small, self-contained change in ask_for_spec_from, so all three commands (show/info/open) benefit since they share select_spec. Non-interactive use (pipes/CI, or when io/console is unavailable)
transparently falls back to the current line-based prompt, so existing behaviour and specs are preserved.
Note: input is restricted to valid digits
On the interactive path this also tightens input handling. Today the prompt reads a line and runs .to_i, so a typo like abc becomes 0 and exits, and 2x becomes 2. With single-keypress selection, non-digit keys (and digits that can't form a valid option number) are simply ignored, so a stray keystroke can no longer exit or mis-select. 0 still exits and Ctrl-C still aborts. The non-interactive fallback retains the current .to_i behaviour, so this stricter validation applies only to the live TTY prompt.
Open questions
Opt-out? Raw single-keypress input can surprise some terminals / screen-readers / automation. Should this sit behind a config setting (e.g. BUNDLE_SINGLE_KEYPRESS_SELECT, default on), or just be the default
with the non-TTY fallback as the escape hatch?
I have a working implementation with unit specs (bin/rspec spec/bundler/cli_common_spec.rb green, rubocop clean) and can open a PR if this seems worthwhile.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to check if the following idea warrants a PR.
Working with claude-code, I got used to just selecting the number of an option when being offered choices (i.e. no need for Return). This made the current behaviour of e.g.
bundle show <ambiguous name>stand out as added friction,as Return is currently always needed.
Current behaviour
When a name matches more than one gem, bundle show/info/open print a numbered menu (via
Bundler::CLI::Common#ask_for_spec_from) and read a whole line:Proposal
Accept the choice on a single keypress as soon as it's unambiguous, i.e. when no larger option number has the typed digits as a prefix:
selecting 1 while 10 exists). Backspace edits, Ctrl-C aborts.
It's a small, self-contained change in ask_for_spec_from, so all three commands (show/info/open) benefit since they share select_spec. Non-interactive use (pipes/CI, or when io/console is unavailable)
transparently falls back to the current line-based prompt, so existing behaviour and specs are preserved.
Note: input is restricted to valid digits
On the interactive path this also tightens input handling. Today the prompt reads a line and runs .to_i, so a typo like abc becomes 0 and exits, and 2x becomes 2. With single-keypress selection, non-digit keys (and digits that can't form a valid option number) are simply ignored, so a stray keystroke can no longer exit or mis-select. 0 still exits and Ctrl-C still aborts. The non-interactive fallback retains the current .to_i behaviour, so this stricter validation applies only to the live TTY prompt.
Open questions
with the non-TTY fallback as the escape hatch?
bundle infois not using exact match #9441 / Implement--exact-matchFlag forbundle info/show/open#9489. Those propose --exact-match to avoid the menu entirely; this proposal instead makes the menu faster when it does appear. They seem complementary rather than competing - does thatmatch your thinking?
I have a working implementation with unit specs (bin/rspec spec/bundler/cli_common_spec.rb green, rubocop clean) and can open a PR if this seems worthwhile.
Beta Was this translation helpful? Give feedback.
All reactions