Title: Update cmd2.Cmd.select to use prompt-toolkit choice by tleonhardt · Pull Request #1600 · python-cmd2/cmd2 · GitHub
Open Graph Title: Update cmd2.Cmd.select to use prompt-toolkit choice by tleonhardt · Pull Request #1600 · python-cmd2/cmd2
X Title: Update cmd2.Cmd.select to use prompt-toolkit choice by tleonhardt · Pull Request #1600 · python-cmd2/cmd2
Description: The choice function from prompt-toolkit is now used for cmd2.Cmd.select method when both stdin and stdout are TTYs. Key Changes: prompt_toolkit.shortcuts.choice integration: The select method now utilizes the modern, interactive choice shortcut when both stdin and stdout are TTYs. This provides a more user-friendly selection menu (usually supports arrow keys and searching). Backward Compatibility: Maintained the original numbered-list implementation as a fallback for non-TTY environments. This ensures that existing scripts, pipes, and tests (which mock read_input) continue to function correctly. Robust Argument Handling: Standardized the conversion of various input formats (strings, lists of strings, lists of tuples) to the (value, label) format required by choice. Error Handling: Wrapped the choice call in a loop and a try-except block to correctly handle KeyboardInterrupt (Ctrl-C) by printing ^C and re-raising, and to handle cancellations by reprompting, maintaining consistency with original select behavior.
Open Graph Description: The choice function from prompt-toolkit is now used for cmd2.Cmd.select method when both stdin and stdout are TTYs. Key Changes: prompt_toolkit.shortcuts.choice integration: The select method now ...
X Description: The choice function from prompt-toolkit is now used for cmd2.Cmd.select method when both stdin and stdout are TTYs. Key Changes: prompt_toolkit.shortcuts.choice integration: The select method now ...
Opengraph URL: https://github.com/python-cmd2/cmd2/pull/1600
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e364dd71-f81b-f155-c53f-a770791c5eff |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C602:9C16A:54F59A:7C2059:6A4E0C14 |
| html-safe-nonce | 8af8e6b4f73dcc8382e0b3d4509404fad3b7e748bcc786200f666c6558a4004a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjAyOjlDMTZBOjU0RjU5QTo3QzIwNTk6NkE0RTBDMTQiLCJ2aXNpdG9yX2lkIjoiNTkzOTIwMTc1NTAzNjEyNjIyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 684cb04f5b468327b32335a65fd7b7a0864dc4278de0db723cb71b557df3349a |
| hovercard-subject-tag | pull_request:3366326446 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-cmd2/cmd2/pull/1600/files |
| twitter:image | https://avatars.githubusercontent.com/u/2812720?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2812720?s=400&v=4 |
| og:image:alt | The choice function from prompt-toolkit is now used for cmd2.Cmd.select method when both stdin and stdout are TTYs. Key Changes: prompt_toolkit.shortcuts.choice integration: The select method now ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python-cmd2/cmd2 git https://github.com/python-cmd2/cmd2.git |
| octolytics-dimension-user_id | 17161025 |
| octolytics-dimension-user_login | python-cmd2 |
| octolytics-dimension-repository_id | 51442999 |
| octolytics-dimension-repository_nwo | python-cmd2/cmd2 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 51442999 |
| octolytics-dimension-repository_network_root_nwo | python-cmd2/cmd2 |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 51470c353b8a1f52a88d3e3cc2014b17ab8cc1ce |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width