-
-
Save aycabta/ad0a1cc317e74939f348 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
#!/usr/bin/env ruby | |
require 'optparse' | |
run_interval_milli_second = 1000 | |
opt = OptionParser.new | |
opt.on('-i VAL') { |v| run_interval_milli_second = v.to_i } | |
opt.parse!(ARGV) | |
str = ARGV.empty? ? ARGF.read : ARGV.join(' ') | |
str.chomp.split(/(?=.)/).inject do |run_str, c| | |
print "#{run_str}\r" | |
sleep run_interval_milli_second / str.length / 1000.0 | |
run_str + c | |
end | |
print "#{str}\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment