Sha256: 9d041be4ae61f605f0d7ac8495f1d0e1026c96e86cae50c867f396e87d409691
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 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, __FILE__) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.2.0 | examples/hello/hello |