Skip to content

Interactive shell#89

Merged
scribu merged 17 commits into
masterfrom
repl
Oct 30, 2012
Merged

Interactive shell#89
scribu merged 17 commits into
masterfrom
repl

Conversation

@scribu
Copy link
Copy Markdown
Member

@scribu scribu commented Oct 28, 2012

It would be interesting to have a command that would open an interactive read-eval-print-loop console, similar to wpshell.

Example usage:

$ wp shell
wp> get_option('home')
'http://wp.dev/core'
wp> strtoupper($_)
'HTTP://WP.DEV/CORE'

@scribu
Copy link
Copy Markdown
Member Author

scribu commented Oct 30, 2012

I think this is a good start.

scribu pushed a commit that referenced this pull request Oct 30, 2012
@scribu scribu merged commit 4411a4d into master Oct 30, 2012
scribu added a commit that referenced this pull request Oct 30, 2012
@danielbachhuber
Copy link
Copy Markdown
Member

Any plans to be able to persist between eval()? e.g.:

wp> $users = get_users();
wp> echo wp_list_pluck( $users, 'user_login' );

@scribu
Copy link
Copy Markdown
Member Author

scribu commented Nov 2, 2012

Not sure what you mean. This works as expected:

wp> $users = get_users();
wp> wp_list_pluck( $users, 'user_login' );

scribu added a commit that referenced this pull request Nov 4, 2012
return value, which returns false on error.

see #89
scribu added a commit that referenced this pull request Nov 4, 2012
PHP's readline extension doesn't implement all the features from the
native GNU readline library, such as Ctrl+u.

Plus, a large percentage of PHP installs probably don't even have `--with-readline` enabled.

The method used in this commit was inspired by wpshell.

see #89
@danielbachhuber
Copy link
Copy Markdown
Member

Sorry, partially incorrect bug report. It's confusing that shell stdouts the retval of the function too though.

@scribu
Copy link
Copy Markdown
Member Author

scribu commented Nov 8, 2012

It's how it works in most REPLs; you'll get used to it. :)

@scribu
Copy link
Copy Markdown
Member Author

scribu commented Nov 8, 2012

One way to suppress the output:

wp> 1; $users = get_users();

@danielbachhuber
Copy link
Copy Markdown
Member

I can learn to love it :)

@rmccue
Copy link
Copy Markdown
Contributor

rmccue commented Nov 8, 2012

@scribu Actually, most REPLs won't print if you also assign it to a variable. (Not commenting on what wp-cli should do, just noting it.)

@scribu
Copy link
Copy Markdown
Member Author

scribu commented Nov 8, 2012

irb always prints the result; python doesn't if you assign to a variable. Would be cool if we did it the python way, but PHP's eval() doesn't give us many options.

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

Successfully merging this pull request may close these issues.

3 participants