Sha256: baf8590f85a9e2c3fe23b65c8cab2edcf64b0db65581ef55221e6e58b2c1b333
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
#!/usr/bin/env ruby require File.expand_path('../../helper', __FILE__) # # Say hello # # SYNOPSIS # #{program_name} [--help] [--version] [--capitalize] [WHO] # # OPTIONS # #{summarized_options} # # DESCRIPTION # Without any argument, says hello to the world. When a single argument # is given says hello to the user. # class Hello < Quickl::Command(__FILE__, __LINE__) # Command's version VERSION = "0.1.0" # Install command options options do |opt| # Capitalize user name? opt.on("--capitalize", "-c", "Capitalize user name") do @capitalize = true end # Show the help and exit opt.on_tail("--help", "Show help") do raise Quickl::Help end # Show version and exit opt.on_tail("--version", "Show version") do raise Quickl::Exit, "#{program_name} #{VERSION} (c) 2010, Bernard Lambeau" end end # Execute the command on some arguments def execute(args) if args.size <= 1 name = args.first || "world" name = name.capitalize if @capitalize puts "Hello #{name}!" else raise Quickl::InvalidArgument, "Useless arguments: #{args.join(' ')}" end end end # class Hello if __FILE__ == $0 Hello.run(ARGV) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.1.1 | examples/hello/hello |