Class: JabberTee::Executor

Inherits:
Object
  • Object
show all
Includes:
Choosy::Terminal
Defined in:
lib/jabber-tee/executor.rb

Constant Summary collapse

JABBER_FILE_LOCATIONS =
[
  File.join(ENV['HOME'], '.jabber-tee.yml'),
  '/etc/jabber-tee.yml'
]

Instance Method Summary collapse

Instance Method Details

#execute!(args, options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jabber-tee/executor.rb', line 15

def execute!(args, options)
  command = format_command(args)
  if command && stdin?
    die "Cannot both execute command and read from STDIN"
  elsif command.nil? && !stdin?
    die "Unable to read from STDIN"
  end

  client = create_client(options)
  code = pipe_in(command) do |line|
    client.say(line)
    puts line
  end

  exit code.to_i
end