bin/destroy in loremarkov-0.0.0.3 vs bin/destroy in loremarkov-0.0.0.4

- old
+ new

@@ -6,10 +6,29 @@ exit 1 end require 'loremarkov' -filename = ARGV.first or usage "provide an input file" -num_prefixes = ARGV[1] ? ARGV[1].to_i : 5 -text = File.read(filename) +# accept text from STDIN or filename +# +if $stdin.tty? + # from file or sample + filename = ARGV.shift || 'lorem_ipsum' + unless File.exists?(filename) + filename = File.join(__dir__, '..', 'text', filename) + end + raise("unknown file: #{filename}:") unless File.exists?(filename) + text = File.read(filename) +else + # from STDIN + text = $stdin.read +end + +# destruction parameter engage (default 5) +# +num_prefixes = ARGV.shift +num_prefixes = num_prefixes ? 5 : num_prefixes.to_i + +# DESTROY!!!!! +# puts Loremarkov.new(num_prefixes).destroy text