# File lib/mongrel/command.rb, line 174
174:       def run(args)
175:         # find the command
176:         cmd_name = args.shift
177: 
178:         if !cmd_name or cmd_name == "?" or cmd_name == "help"
179:           print_command_list
180:           return true
181:         elsif cmd_name == "--version"
182:           STDERR.puts "Mongrel Web Server #{Mongrel::Const::MONGREL_VERSION}"
183:           return true
184:         end
185: 
186:         begin
187:           # quick hack so that existing commands will keep working but the Mongrel:: ones can be moved
188:           if ["start", "stop", "restart"].include? cmd_name
189:             cmd_name = "mongrel::" + cmd_name
190:           end
191: 
192:           command = GemPlugin::Manager.instance.create("/commands/#{cmd_name}", :argv => args)
193:         rescue OptionParser::InvalidOption
194:           STDERR.puts "#$! for command '#{cmd_name}'"
195:           STDERR.puts "Try #{cmd_name} -h to get help."
196:           return false
197:         rescue
198:           STDERR.puts "ERROR RUNNING '#{cmd_name}': #$!"
199:           STDERR.puts "Use help command to get help"
200:           return false
201:         end
202: 
203:         # Normally the command is NOT valid right after being created
204:         # but sometimes (like with -h or -v) there's no further processing
205:         # needed so the command is already valid so we can skip it.
206:         if not command.done_validating
207:           if not command.validate
208:             STDERR.puts "#{cmd_name} reported an error. Use mongrel_rails #{cmd_name} -h to get help."
209:             return false
210:           else
211:             command.run
212:           end
213:         end
214: 
215:         return true
216:       end