8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pmt/cli.rb', line 8
def run
program :name, 'pmt'
program :version, Pmt::VERSION
program :description, 'Command that prints a multiplication table of the first N prime numbers'
command :print do |c|
c.syntax = 'pmt print [options]'
c.description = 'Prints a multiplication table of the first N prime numbers'
c.option '--count NUMBER', Integer, 'The number of prime numbers to print'
c.action do |args, options|
options.default(
count: 10
)
if options.count < 1
puts "The count option must be a positive value"
else
puts MultiplicationTable.new(options.count).to_s
end
end
end
default_command :print
run!
end
|