Method: Blufin::Terminal.print_files_written
- Defined in:
- lib/core/terminal.rb
permalink .print_files_written(array_of_paths_or_files, message = nil, limit = 10, preceding_blank_line = true) ⇒ Object
Outputs Array of files/directories in a pretty, standardized format.
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/core/terminal.rb', line 578 def self.print_files_written(array_of_paths_or_files, = nil, limit = 10, preceding_blank_line = true) raise RuntimeError, "Expected Array of files, instead got: #{array_of_paths_or_files.class}" unless array_of_paths_or_files.is_a?(Array) = "Wrote the following #{Blufin::Terminal::format_highlight('files/directories')}" if .nil? limit = limit.nil? ? 99999999999 : limit.to_i file_output = [] file_count = 0 file_more = 0 array_of_paths_or_files.compact! array_of_paths_or_files.sort! array_of_paths_or_files.each do |path_or_file| file_count += 1 if file_count > limit file_more += 1 next end if Blufin::Files::path_exists(path_or_file) file_output << "Path: \x1B[38;5;248m#{path_or_file.strip}\x1B[0m" else file_output << "File: \x1B[38;5;46m#{path_or_file.strip}\x1B[0m" end end file_output << "\x1B[38;5;168m#{file_more} more...\x1B[0m" if file_more > 0 Blufin::Terminal::automatic(, file_output, preceding_blank_line) end |