Class: JetBlack::InteractiveCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/jet_black/interactive_command.rb

Instance Method Summary collapse

Instance Method Details

#call(raw_command:, raw_env:, directory:, block:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jet_black/interactive_command.rb', line 6

def call(raw_command:, raw_env:, directory:, block:)
  env = Environment.new(raw_env).to_h
  terminal = TerminalSession.new(raw_command, env: env, directory: directory)

  unless block.nil?
    block.call(terminal)
  end

  terminal.wait_for_finish

  ExecutedCommand.new(
    raw_command: raw_command,
    stdout: terminal.stdout,
    stderr: terminal.stderr,
    exit_status: terminal.exit_status,
  )
end