In the third episode of the series, I build a command-line interface for the Converty gem driven out by RSpec tests to show how to assert against stdout and stderr. This allows people to call out to Converty right from the terminal, for example: `converty 5 --from km --to mi --round 1` which outputs 3.1.
Table of contents:
00:00 - Intro
01:25 - Help docs
08:53 - Parsing arguments
12:40 - Calling out to our gem code
23:01 - Requiring arguments
32:39 - CLI demo
OptionParser docs: https://ruby-doc.org/stdlib-2.7.1/libdoc/optparse/rdoc/OptionParser.html
Thor, an alternative to OptionParser: http://whatisthor.com/
View the code from this episode: https://github.com/monoso/converty/commit/ee73f072e62473ef05a46ed52016919452aaf995
Ruby version: 2.6.5
Bundler version: 2.2.16
Ruby Gem version: 3.0.6
Download
0 formats
No download links available.
Building a Ruby CLI (Let's Build a Ruby Gem, Ep 03) | NatokHD