Repository URL to install this package:
|
Version:
1.1 ▾
|
#!/usr/bin/env ruby
#
# demoappl -- Just test the Application class
#
require "appl"
class DemoAppl < Application
NAME = "demoappl"
VERSION = "1.0"
SUMMARY = "Just test the Application class"
COPYRIGHT = "(C) 2011 Bertram Scharpf"
LICENSE = "For internal use only"
AUTHOR = "Bertram Scharpf <software@bertram-scharpf.de>"
DESCRIPTION = <<EOT
This is an example how to define an Application subclass.
The program just prints out its parameters.
EOT
OPTIONS_ENV = "DEMO_OPTS"
attr_writer :param, :default_param
attr_bang :switch, :raise, :debug
define_option "s", :switch!, "dummy switch"
alias_option "s", "switch"
define_option "p", :param=, "PARAM", "dummy parameter"
alias_option "p", "param"
define_option "d", :default_param=, "PARAM:dddd",
"dummy parameter with default value"
alias_option "d", "default-param"
define_option "r", :raise!, "raise an exception"
alias_option "r", "raise"
define_option "g", :debug!, "lots of ugly debugging information"
alias_option "g", "debug"
define_option "h", :help, "show this options list"
alias_option "h", "help"
define_option "V", :version, "show version information"
alias_option "V", "version"
UNKNOWN = "Sorry, unknown option"
STOPOPT = "no more options"
UNPROCA = "Warning: unprocessed arguments left"
def run
puts inspect
raise "stop" if @raise
ENV[ OPTIONS_ENV] or
puts "Try to set the environment variable #{OPTIONS_ENV}."
@args.clear
end
end
if false then
DemoAppl.run %w(-s -p rrrr qqqq -x -y -z)
else
DemoAppl.run
end