-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support readline or equivalent alternatives #7
Comments
I don't know much about readline, but will supporting it allow us to use left/right arrow keys in the prompts? |
@achimnol Thank you for creating an issue, this is very interesting. I'm not knowledgeable enough about Meaning those streams can either come from:
As @dufferzafar pointed out, it would nice to have support of left/right arrow keys for all those use cases, but I have no idea whether this is doable yet. It would also be worth looking into prompt_toolkit as well, since it has asyncio support. Any help is more than welcome by the way 😉 |
Yeah, I recently had to build an asyncio based CLI and found out that prompt_toolkit has support for it. I think that is our best bet to create an awesome async-cli. Haven't looked into the specifics yet, but will definitely post anything I learn here. |
I tried to add support for readline with low-level, callback-based readline API, but it segfaults mysteriously in the callback. I might investigate further, but this will surely only support read from terminal. If you connect via TCP, you can just use |
@lilydjwg How does the socat option work? I ran the echo example and I can connect fine w/ nc but when I try to say socat readline anything, I just get an error (using the latest version of socat):
|
@TD22057 There seems to be a problem with socat and readline. Instead you can use rlwrap: # Works with local apython console
$ rlwrap apython
# Also works with a remote console
$ apython --serve locahost:8888
The console is being served on 127.0.0.1:8888
# with both netcat and socat
$ rlwrap nc localhost 8888
$ rlwrap socat - tcp:localhost 8888 I actually didn't know about Thanks for your post. |
rlwrap works perfectly and is exactly what I need for my application. Thanks for this very cool project. |
Hi all, I just implemented readline support (PR #9) for local console through the The implementation is hackish but contained, and can even be disabled using the Feel free to review the PR if you're interested. Otherwise, I'll probably merge it next week (or not, if I change my mind and finally consider it's too hackish :) ). Thanks for your inputs! |
PR #9 is merged, readline support for linux is now available with version 0.1.4. |
Googling leads me to this SO question but there is no reply yet.
Python already provides a binding module to GNU readline or libedit, but this does not work together with aioconsole since it does not have coroutine-based interfaces. Maybe we need a new lower-level wrapper for the readline library.
This issue is both question and feature request:
The text was updated successfully, but these errors were encountered: