class Spawn
Format a spawn event, including the command and arguments.
Definitions
KEY = :spawn
The key used to identify this formatter.
def initialize(terminal)
Create a new spawn formatter.
Implementation
def initialize(terminal)
@terminal = terminal
@terminal[:spawn_command] ||= @terminal.style(:blue, nil, :bold)
end
def format(event, stream, verbose: false, width: 80)
Format the given event.
Signature
-
parameter
event
Hash
The event to format.
-
parameter
stream
IO
The stream to write the formatted event to.
-
parameter
verbose
Boolean
Whether to include additional information.
-
parameter
width
Integer
The width of the progress bar.
Implementation
def format(event, stream, verbose: false, width: 80)
environment, arguments, options = event.values_at(:environment, :arguments, :options)
arguments = arguments.flatten.collect(&:to_s)
stream.puts "#{@terminal[:spawn_command]}#{arguments.join(' ')}#{@terminal.reset}#{chdir_string(options)}"
if verbose and environment
environment.each do |key, value|
stream.puts "export #{key}=#{value}"
end
end
end
def chdir_string(options)
Generate a string to represent the working directory.
Implementation
def chdir_string(options)
if options and chdir = options[:chdir]
" in #{chdir}"
end
end