Six weeks go by quickly, especially when you’re learning a skill that plunges you ever deeper into an endless world of excitement. Looking back, I can hardly believe I’ve learned as much as I have.
I started my CLI project about two weeks ago, thinking I knew what I needed to complete it. But I wanted to solidify that knowledge. Practice makes perfect. But creative practice fills in the gaps you didn’t know were there.
The project needed to scrape a website, provide the user with information, and have a command-line interface to interact with the program. I chose to scrape an event schedule to create an agenda for the user (GDG DevFest 2018). While properly learning to iterate through, filter, and attach my scraped results to an object, my best friend was Pry.
I could go on and on about my love for Pry. But I’ll try to share a few of my favorite commands of Pry instead. While the most fundamental benefit of Pry is to essentially ‘pry’ open code, there is so much more to it.
If you’re familiar with the terminal on a Unix system, you’ve probably used the ‘ls’ command to list files and folders. Pry has something similar. The ‘ls’ command will show you a list of possible methods and variables for the location you pried open. While this may seem like a trivial command by itself, when combined with other commands, it becomes mighty.
Which brings me to my next command, ‘play’. More specifically, ‘play -l’ will play the line specified next. This command also provides a relatively easy way to step into or around blocks and iterations. When it’s combined with ‘ls’, you can follow changes to variables and methods as they happen.
My last command is more of a tip of how to use a command than an actual command. While outside of a ‘do’ block, ‘exit’ will exit from the program. But while inside, it can provide valuable information about each iteration the block goes through, giving much needed debugging support.
Overall, this was a very tiny piece of what I’ve learned about this project. But I’ll save that for another post. The journey continues!