Created
April 24, 2018 13:55
-
-
Save nisevi/eb77fa3288f4559012751511e2e04b61 to your computer and use it in GitHub Desktop.
File where command line options are handled.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'methadone' | |
require 'primes_table.rb' | |
class App | |
include Methadone::Main | |
include Methadone::CLILogging | |
main do | |
rows = options[:rows].to_i < 10 ? 10 : options[:rows].to_i | |
columns = options[:columns].to_i < 10 ? 10 : options[:columns].to_i | |
args = { rows: rows, columns: columns } | |
matrix = Matrix.new(args) | |
matrix.print | |
end | |
description 'Prints out a multiplication table of the first N prime numbers.' | |
on('-r ROWS', '--rows', 'Amount of rows in table. Must be integer. Default value is 10.') | |
on('-c COLUMNS', '--columns', 'Amount of columns in the table. Must be integer. Default value is 10.') | |
version PrimesTable::VERSION | |
go! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment