-
Notifications
You must be signed in to change notification settings - Fork 178
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
Add auto-completion feature #205
Add auto-completion feature #205
Conversation
def eval(input) | ||
"=> #{@binding.eval(input).inspect}\n" | ||
def eval(input, rawdata = nil) | ||
rawdata ? @binding.eval(input) : "=> #{@binding.eval(input).inspect}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of introducing a condition here, can we save the current selected binding in the session object? That way, we can evaluate code in an evaluator object and inspect the variables with the binding itself.
8920b1b
to
263eea7
Compare
263eea7
to
4e0e127
Compare
Updated (it's still working in progress). Currently supported input casesFor now, I have supported below input cases. Any other input case?
r? @gsamokovarov Could you please review the code again? 🙇 Thank you. |
s.is_a?(String) && !s.empty? && !s.match(/[^a-zA-Z0-9\@\$\.\:]/) | ||
end | ||
|
||
def context_eval(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that a Context
object is emerging here. Do you wanna move all this code to lib/web_console/context.rb
in a WebConsole::Context
class. We can feed it the command and have the current global context as state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you wanna move all this code to lib/web_console/context.rb in a WebConsole::Context class.
Yeah, I wanna do that. 👍 Could you show some interface you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about WebConsole::Context as follows:
>> c = Context.new(@current_binding)
>> c.global
>> c.of(obj)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something similar, yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will try it
4e0e127
to
2be719d
Compare
Great! Thanks for the awesome feature, Hiroyuki. 🙇 |
@@ -0,0 +1,46 @@ | |||
module WebConsole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a unit-test for that class before release. :-)
Thank you so much @sh19910711! I'll straight on merge this one now and we can work on the remaining features in separate smaller PRs. |
Auto Completion on Web Console
This pull request is to add the "Auto-Completion" feature to help typing commands on Web Console. For example, if people type the TAB key when typing the prefix of some commands, then it shows the list of possible commands from the prefix.
Demo
Things have not been done yet
>> some.foo<TAB>
>> somemethod(foo<TAB>
>> Some<TAB>
>> Some::Thing<TAB>
Let me know if you have another feature idea of the auto-completion feature.
r? @gsamokovarov # Could you please review the current changes? 🙇
Thanks.