Sha256: 69338b6ab9d0a4d82ebe472c0c1b41c062629dcc7d25a59efd109eec64399215

Contents?: true

Size: 504 Bytes

Versions: 3

Compression:

Stored size: 504 Bytes

Contents

#! /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", :attribute_name => :words

  def execute

    the_truth = words.join(" ")
    the_truth.upcase! if loud?

    iterations.times do
      puts the_truth
    end

  end

end

SpeakCommand.run

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clamp-0.1.2 examples/speak
clamp-0.1.1 examples/speak
clamp-0.1.0 examples/speak