class Console::Event::Spawn

“‘
event.status = Process.wait
event = Console::Event::Spawn.for(“ls”, “-l”)
Console.info(self, **Console::Event::Spawn.for(“ls”, “-l”))
“`ruby
Represents a spawn event.

def self.for(*arguments, **options)

def self.for(*arguments, **options)
	# Extract out the command environment:
	if arguments.first.is_a?(Hash)
		environment = arguments.shift
		self.new(environment, arguments, options)
	else
		self.new(nil, arguments, options)
	end
end

def duration

def duration
	if @end_time
		@end_time - @start_time
	end
end

def emit(*arguments, **options)

def emit(*arguments, **options)
	options[:severity] ||= :info
	super
end

def initialize(environment, arguments, options)

def initialize(environment, arguments, options)
	@environment = environment
	@arguments = arguments
	@options = options
	
	@start_time = Clock.now
	
	@end_time = nil
	@status = nil
end

def status=(status)

def status=(status)
	@end_time = Time.now
	@status = status
end

def to_hash

def to_hash
	Hash.new.tap do |hash|
		hash[:type] = :spawn
		hash[:environment] = @environment if @environment&.any?
		hash[:arguments] = @arguments if @arguments&.any?
		hash[:options] = @options if @options&.any?
		
		hash[:status] = @status.to_i if @status
		
		if duration = self.duration
			hash[:duration] = duration
		end
	end
end