Searching with Picky: In the Terminal Tweet
This is a post in the Picky series on its workings. If you haven’t tried it yet, do so in the Getting Started section. It’s quick and painless :)
This post is about a fun little experimental toy I’ve been working on: picky search <url>
.
Update!
rake search
is picky search
from 2.2.0 on.
picky search <url>?
Yes. While working on a server, I sometimes want to see if the search engine works correctly directly in the terminal (normally I use tests, but sometimes I need that quick look).
How do I use it?
See this short video (it’s best to full-screen it):
- Start a Picky server.
- Then type
picky search /some/url
(where/some/url
is a path – or url if not on this server – you’ve defined usingroute
inapp/application.rb
). - Then, just type away.
The result id count will update as you type.
When pressing enter, the top 20 result ids will appear next to your search text.
If you want to exit, just Ctrl-C
. That’s it.
Note that you need the picky-client & highline gem installed. But Picky will tell you so if you haven’t.
How does it work?
I use the highline gem (by @JEG2) to get single characters (using the appropriately named get_character
) from the user and then move the cursor around using \e[#{amount}D
(left) and \e[#{amount}C
(right), print
ing to the STDOUT and flush
ing it a lot.
If there is a gem which makes it easy to position objects in the terminal which update it (by being used in a visitor pattern or however), I’d like to hear about it!
Conclusion
So we’ve seen
- how you run a search directly in the terminal.
Hope you learnt something new!
Next Picky Data Sources: Next StepsShare
Previous Searching with Picky: Range/Area/Volume etc. Search