examples/speak in clamp-0.0.9 vs examples/speak in clamp-0.1.0
- old
+ new
@@ -1,21 +1,22 @@
#! /usr/bin/env ruby
+# A simple Clamp command, with options and parameters
+
require "clamp"
class SpeakCommand < Clamp::Command
option "--loud", :flag, "say it loud"
option ["-n", "--iterations"], "N", "say it N times", :default => 1 do |s|
Integer(s)
end
- parameter "WORDS ...", "the thing to say"
+ parameter "WORDS ...", "the thing to say", :attribute_name => :words
def execute
- signal_usage_error "I have nothing to say" if arguments.empty?
- the_truth = arguments.join(" ")
+ the_truth = words.join(" ")
the_truth.upcase! if loud?
iterations.times do
puts the_truth
end