Skip to content
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

Prompting doesn't support arrow keys #72

Closed
rodrigoprimo opened this issue Nov 27, 2014 · 1 comment
Closed

Prompting doesn't support arrow keys #72

rodrigoprimo opened this issue Nov 27, 2014 · 1 comment

Comments

@rodrigoprimo
Copy link
Contributor

From: wp-cli/wp-cli#996

Prompting doesn't support arrow keys because php-cli-tools uses fgets(STDIN) instead of readline:

https://github.com/wp-cli/php-cli-tools/blob/master/lib/cli/Streams.php#L130

The following seem to fix this issue:

diff --git a/lib/cli/Streams.php b/lib/cli/Streams.php
index b750636..081a6bd 100755
--- a/lib/cli/Streams.php
+++ b/lib/cli/Streams.php
@@ -126,6 +126,8 @@ class Streams {

                if( $format ) {
                        fscanf( static::$in, $format . "\n", $line );
+               } else if ( function_exists( 'readline' ) ) {
+                       $line = readline();
                } else {
                        $line = fgets( static::$in );
                }

But, at least for wp-cli --prompt parameter, another problem is created. If you use the left arrow to go to the beginning of what you typed, the cursor goes to the beginning of the line, before the question presented to the user. I think this happens because readline() expects the question as a parameter. So we will need to change that as well.

@danielbachhuber
Copy link
Member

I'm switching to readline() in WP-CLI for this — don't think it needs to be fixed in php-cli-tools.

See wp-cli/wp-cli#2325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants