Permalink
Browse files

utils/stress: improve a bit usability

  • Loading branch information...
1 parent 5f1174e commit 6421d345035dd48ffbb3266bef0e3f9d6ae646f2 @meh committed Jul 16, 2011
Showing with 16 additions and 10 deletions.
  1. +16 −10 utils/stress.rb
View
@@ -158,7 +158,7 @@ def spawn
}
module Readline
- Commands = ['exit', 'quit', 'send', 'clients']
+ Commands = ['!exit', '!quit', '!clients']
Prefix = '>> '.bold
def self.supported?
@@ -172,6 +172,8 @@ def self.supported?
if supported?
self.completion_proc = proc {|s|
+ next unless s.start_with?('!')
+
Commands.grep(/^#{Regexp.escape(s)}/)
}
end
@@ -200,17 +202,21 @@ def self.readline_with_hist_management
if Readline.supported?
while line = Readline.readline_with_hist_management
- case line
- when 'exit', 'quit'
- exit!
- when /^send\s+(.*?)$/
- @input.push eval("%{#{$1}}")
- @sockets.wakeup
+ if line.start_with?('!')
+ case line[1 .. -1]
+ when 'exit', 'quit'
+ exit!
+
+ when /^clients\s+(.*)$/
+ next if $1.to_i == 0
- when /^clients\s+(.*)$/
- @sockets.number = $1.to_i
- @sockets.wakeup
+ @sockets.number = $1.to_i
+ @sockets.wakeup
+ end
+ else
+ @input.push eval("%{#{line}}")
+ @sockets.wakeup
end
end
else

0 comments on commit 6421d34

Please sign in to comment.