A Singleton class that manages all of the available commands and handles running them.
Builds a list of possible commands from the Command derivates list
# File lib/mongrel/command.rb, line 150 150: def commands 151: return [] # Neutered 152: pmgr = GemPlugin::Manager.instance 153: list = pmgr.plugins["/commands"].keys 154: return list.sort 155: end
Prints a list of available commands.
# File lib/mongrel/command.rb, line 158 158: def print_command_list 159: puts "#{Mongrel::Command::BANNER}\nAvailable commands are:\n\n" 160: 161: self.commands.each do |name| 162: if /mongrel::/ =~ name 163: name = name[9 .. 1] 164: end 165: 166: puts " - #{name[1 .. -1]}\n" 167: end 168: 169: puts "\nEach command takes -h as an option to get help." 170: 171: end
Runs the args against the first argument as the command name. If it has any errors it returns a false, otherwise it return true.
# File lib/mongrel/command.rb, line 176 176: def run(args) 177: # find the command 178: cmd_name = args.shift 179: 180: if !cmd_name or cmd_name == "?" or cmd_name == "help" 181: print_command_list 182: return true 183: elsif cmd_name == "--version" 184: puts "Mongrel Web Server #{Mongrel::Const::MONGREL_VERSION}" 185: return true 186: end 187: 188: begin 189: # quick hack so that existing commands will keep working but the Mongrel:: ones can be moved 190: if ["start", "stop", "restart"].include? cmd_name 191: cmd_name = "mongrel::" + cmd_name 192: end 193: 194: # Neutered 195: # command = GemPlugin::Manager.instance.create("/commands/#{cmd_name}", :argv => args) 196: rescue OptionParser::InvalidOption 197: STDERR.puts "#$! for command '#{cmd_name}'" 198: STDERR.puts "Try #{cmd_name} -h to get help." 199: return false 200: rescue 201: STDERR.puts "ERROR RUNNING '#{cmd_name}': #$!" 202: STDERR.puts "Use help command to get help" 203: return false 204: end 205: 206: # Normally the command is NOT valid right after being created 207: # but sometimes (like with -h or -v) there's no further processing 208: # needed so the command is already valid so we can skip it. 209: if not command.done_validating 210: if not command.validate 211: STDERR.puts "#{cmd_name} reported an error. Use mongrel_rails #{cmd_name} -h to get help." 212: return false 213: else 214: command.run 215: end 216: end 217: 218: return true 219: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.