SYNOPSIS
Executioner Base Class
Using Executioner is straight-forward. Simply subclass Executioner and add
methods to handle command-line options and nested Executioner classes to
handle sub-commands. A writer method (ending in ’=’) corresponds
to an option. if a query method (ending in ’?’) of the same name
exists then it is considered a boolean flag. And a bang method
(ending in ’!’) indicates an "immediate" option.
For example, here is a simple commandline tool to run a Ruby script.
require 'executioner'
class Run < Executioner
help "Require LIBRARY before executing your script"
def require=(lib)
require lib
end
alias :r= :require=
help "Include PATH in $LOAD_PATH"
def include=(path)
$:.unshift path
end
alias :I= :include=
help "Run in DEBUG mode"
def debug=(bool)
$DEBUG = bool
end
def debug?
$DEBUG
end
help "Show this message"
def help!
puts self
exit
end
alias :h! :help!
def main(script)
load(script)
end
end
For a more detailed example see EXAMPLE.rdoc.