Class: Switchboard::Commands::Grep

Inherits:
Switchboard::Command show all
Defined in:
lib/switchboard/commands/grep.rb

Class Method Summary collapse

Methods inherited from Switchboard::Command

description, help, options, to_command, to_command_name

Class Method Details

.run!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/switchboard/commands/grep.rb', line 6

def self.run!
  expr = ARGV.pop

  switchboard = Switchboard::Client.new
  switchboard.plug!(AutoAcceptJack, NotifyJack)

  switchboard.on_stanza do |stanza|
    # TODO doesn't handle default namespaces properly
    REXML::XPath.each(stanza, expr) do |el|
      puts el.to_s
    end
  end

  switchboard.run!
end