https://github.com/deadsy/py_linenoise
A port of the linenoise line editor to Python.
https://github.com/deadsy/py_linenoise
cli command-line line-editor linenoise python readline
Last synced: 5 months ago
JSON representation
A port of the linenoise line editor to Python.
- Host: GitHub
- URL: https://github.com/deadsy/py_linenoise
- Owner: deadsy
- License: mit
- Created: 2016-03-12T16:10:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-17T17:37:18.000Z (about 2 years ago)
- Last Synced: 2024-05-17T18:26:17.960Z (about 2 years ago)
- Topics: cli, command-line, line-editor, linenoise, python, readline
- Language: Python
- Homepage:
- Size: 83 KB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# py_linenoise
A port of linenoise to Python (because sometimes readline doesn't cut it...)
See: http://github.com/antirez/linenoise
## Standard Features
* Single line editing
* Multiline editing
* Input from files/pipes
* Input from unsupported terminals
* History
* Completions
* Hints
## Other Features
* Line buffer initialization: Set an initial buffer string for editing.
* Hot keys: Set a special hot key for exiting line editing.
* Loop Functions: Call a function in a loop until an exit key is pressed.
## Examples
### example1.py
Matches the example code in the C version of the linenoise library.
### example2.py
Implements a heirarchical command line interface using cli.py and the linenoise library.
## Motiviation
The GNU readline library is a standard package in Python, but sometimes it's hard to use:
* How do you have a hot key exit the line editing so you can offer context sensitive help?
* How do you call a polling function during line editing so you can check for other things?
Having a simple, hackable, native Python implementation of line editing makes these things much easier.
The linenoise library in C already offers a simple alternative.
Porting these functions to Python makes it even easier to use on any system with a POSIX compatible terminal environment.