-
-
Save JonnyCodewalker/54137da03409fe3c6024208ab52d71bb to your computer and use it in GitHub Desktop.
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
require "admiral" | |
require "progress" | |
class Utils < Admiral::Command | |
define_help description: "A command that says hello" | |
define_version "0.0.1" | |
define_flag number_of_greetings : UInt32, | |
description: "The number of times to greet the world", | |
default: 1_u32, | |
long: times, | |
short: t, | |
required: true | |
def bla | |
flags.number_of_greetings.times do | |
puts "Hello World" | |
end | |
[1, "hello", 'x'].each do |context| | |
puts context | |
end | |
end | |
def test | |
bar = ProgressBar.new | |
bar.width = 40 | |
total = 0 | |
1000.times do |i| | |
total += i if i%3 == 0 || i%5 == 0 | |
bar.inc if i%10 == 0 | |
sleep 0.001 | |
end | |
p total | |
# p 1000.times.select{|x| x.divisible_by?(3) || x.divisible_by?(5)}.sum | |
end | |
def run | |
return 4 | |
end | |
end | |
Utils.run | |
###################### | |
the respective spec: | |
###################### | |
require "spec" | |
require "../src/utils.cr" | |
describe Utils do | |
it "returns 4" do | |
Utils.run.should eq(4) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment