Skip to content

Instantly share code, notes, and snippets.

@nisevi
Created April 24, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nisevi/eb77fa3288f4559012751511e2e04b61 to your computer and use it in GitHub Desktop.
Save nisevi/eb77fa3288f4559012751511e2e04b61 to your computer and use it in GitHub Desktop.
File where command line options are handled.
#!/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