Class: Console::Terminal::Formatter::Spawn

Inherits:
Object
  • Object
show all
Defined in:
lib/console/terminal/formatter/spawn.rb

Overview

Format spawn events.

Constant Summary collapse

KEY =
:spawn

Instance Method Summary collapse

Constructor Details

#initialize(terminal) ⇒ Spawn

Returns a new instance of Spawn.



13
14
15
16
# File 'lib/console/terminal/formatter/spawn.rb', line 13

def initialize(terminal)
	@terminal = terminal
	@terminal[:spawn_command] ||= @terminal.style(:blue, nil, :bold)
end

Instance Method Details

#format(event, output, verbose: false, width: 80) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/console/terminal/formatter/spawn.rb', line 18

def format(event, output, verbose: false, width: 80)
	environment, arguments, options = event.values_at(:environment, :arguments, :options)
	
	arguments = arguments.flatten.collect(&:to_s)
	
	output.puts "#{@terminal[:spawn_command]}#{arguments.join(' ')}#{@terminal.reset}#{chdir_string(options)}"
	
	if verbose and environment
		environment.each do |key, value|
			output.puts "export #{key}=#{value}"
		end
	end
end