Sha256: e41cc66bea4fd0ba7ef69ff853b287f1ad5d4baca7c9b3d1bd6c72e9c8eed1c6

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 Bytes

Contents

#! /usr/bin/env ruby

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

  argument "WORDS ...", "the thing to say"

  def execute

    signal_usage_error "I have nothing to say" if arguments.empty?
    the_truth = arguments.join(" ")
    the_truth.upcase! if loud?

    iterations.times do
      puts the_truth
    end

  end

end

SpeakCommand.run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clamp-0.0.7 examples/speak