Skip to content

Conversation

@tleonhardt
Copy link
Member

@tleonhardt tleonhardt commented Dec 29, 2025

This WIP/Draft PR migrates from using GNU Readline for user input, tab-completion, and history to using prompt-toolkit for the same purpose.

prompt-toolkit is a pure-Python readline replacement that is fully cross-platform compatible and doesn't rely on the presence of underlying C dynamic libraries. It also opens the door to some advanced features in the future.

All use of readline is removed and the cmd2.rl_utils module has been deleted. There is a new cmd2.pt_utils module in its place. Currently all linting is passing and the documentation builds. This is an early draft and there is likely a bunch of things that need to be considered related to asynicio support, signal handlers, and blocking popen calls. There also should likely be some code cleanup and perhaps some refactoring. But this is at the working prototype stage that can be tweaked.

All tests are passing on Linux and macOS. On Windows there are many test failures and I suspect it is related to the particular Windows test setup in GitHub Actions and how prompt-toolkit interacts with it. But I don't have a Windows VM to test on currently.

TODO:

  • Make sure behavior is working ok on Windows with manual testing on Windows
  • Do a bunch of manual testing related to edge cases on all platforms
  • Decide if we want completion hints shown in the bottom bar or if we want them elsewhere
  • Think about asyncio cases
  • Think about interactions with signal handlers
  • Thank about blocking calls to things like popen

Tons of tests failing and some even getting stuck.
…f the correct arguments to app.complete()

This fixes all of the test_argparse_comleter.py tests.

There are still failing tests in test_cmd2.py, test_history.py, and test_run_pyscript.py as well as a test in test_cmd2.py that gets stuck.
TODO:
- prompt-toolkit history isn't properly initialized with history from a persistent history file, as shown by the remaining failing history test
… of mocking the built-in input function.

There are still 3 failing and 1 skipped test in test_cmd2.py

Additionally, some tests in test_run_pyscript.py are getting stuck.All tests in other files are passing.
Also:
- Fixed make clean so it cleans up code coverage file artifacts
Also added a bottom toolboar for displaying these type hints.
@tleonhardt tleonhardt added this to the 4.0.0 milestone Dec 29, 2025
@tleonhardt tleonhardt added enhancement major dependencies Pull requests that update a dependency file labels Dec 29, 2025
@github-actions
Copy link
Contributor

🤖 Hi @tleonhardt, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.11%. Comparing base (9f32c65) to head (b3bfe66).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1553      +/-   ##
==========================================
+ Coverage   98.94%   99.11%   +0.16%     
==========================================
  Files          21       21              
  Lines        4942     4839     -103     
==========================================
- Hits         4890     4796      -94     
+ Misses         52       43       -9     
Flag Coverage Δ
unittests 99.11% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

🤖 I'm sorry @tleonhardt, but I was unable to process your request. Please see the logs for more details.

@tleonhardt tleonhardt mentioned this pull request Dec 29, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants