class ApplicationFan
Constants
- AVAILCMDS
- NOCOMMAND
- UNKNWNCMD
- W_CMDS
Attributes
commands[RW]
Public Class Methods
find_command(name)
click to toggle source
# File lib/applfan.rb, line 22 def find_command name @commands.find { |c| c::NAME == name or c::ALIASES.include? name } end
help() { || ... }
click to toggle source
Calls superclass method
Application#help
# File lib/applfan.rb, line 27 def help super do if block_given? then yield puts end puts self::AVAILCMDS puts @commands.each { |c| puts " %-*s %s" % [ self::W_CMDS, c.all_names, c::SUMMARY] } end end
Private Class Methods
inherited(sub)
click to toggle source
Calls superclass method
Application::inherited
# File lib/applfan.rb, line 43 def inherited sub sub.instance_eval do @commands = [] const_set :Command, ( Class.new Application do define_singleton_method :inherited do |c| sub.commands.push c super c end define_singleton_method :root do sub end end ) end super end
Public Instance Methods
run() { |sub| ... }
click to toggle source
# File lib/applfan.rb, line 63 def run c = @args.shift c or raise CommandError, self.class::NOCOMMAND cmd = self.class.find_command c cmd or raise CommandError, self.class::UNKNWNCMD % c sub = cmd.new c, (@args.slice! 0, @args.length) yield sub if block_given? sub.execute end