Create command line application with Ruby available via Homebrew

05-Nov-2020 1157
The goal of this article is to show you how you can create your command line application using the Ruby programming language and make it available.Our goal is to build a get_joke application that will render a random joke about Chuck Norris. The command will also be able to parse the following arguments:random - random jokes that should be displayed. By default, one joke is shown, but if you are prepared to read more, you can pass the -r or --random argument with the number of jokes you would like to seefirst_name - the first name you would like to see instead of Chuck. It should be possible to pass the custom first name with -f or --first-name argumentlast_name - the last name you would like to see instead of Norris. It should be possible to pass the custom last name with -l or --last-name argumenthelp - the help command that displays the list of available commands along with the short description. The command is rendered when the -h or --help argument is passed. The command should not display the joke when this argument is passed.As the data source, we will use the http://api.icndb.com/jokes/random endpoint, which provides a nice and simple API for getting jokes about Chuck.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle