Advertisement
Guest User

Untitled

a guest
Apr 25th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.57 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. currently_in_cmd = false
  4.  
  5. STDIN.read.split("\n").each do |a|
  6.         case a
  7.         when /cmd[0-9]+-start/
  8.                 puts "Entering Command #{a}"
  9.                 currently_in_cmd = true
  10.         when /cmd[0-9]+-stop/
  11.                 puts "Exiting command #{a}"
  12.                 currently_in_cmd = false
  13.         else
  14.                 if currently_in_cmd
  15.                         puts "running command: #{a}"
  16.                 else
  17.                         puts "COMMAND ENCOUNTERD OUTSIDE COMMAND BLOCK"
  18.                 end
  19.         end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement