Skip to content

Commit 285cbe3

Browse files
authored
Ruby CLI: Squelch Processing output when silent is passed in (#464)
Fixes #347 ### Without `silent` flag: ``` ruby -I lib exe/herb analyze examples --no-log-file --non-interactive Processing [1/16]: attributes_with_empty_value.html.erb Processing [2/16]: begin.html.erb Processing [3/16]: block.html.erb Processing [4/16]: case_when.html.erb Processing [5/16]: comment.html.erb Processing [6/16]: doctype.html.erb Processing [7/16]: erb.html.erb Processing [8/16]: for.html.erb Processing [9/16]: if_else.html.erb Processing [10/16]: line-wrap.html.erb Processing [11/16]: nested_if_and_blocks.html.erb Processing [12/16]: simple_block.html.erb Processing [13/16]: simple_erb.html.erb Processing [14/16]: test.html.erb Processing [15/16]: until.html.erb Processing [16/16]: while.html.erb Completed processing all files. --- SUMMARY -------------------------------------------------------------------- Total files: 16 ✅ Successful: 16 (100.0%) ❌ Failed: 0 (0.0%) ⚠️ Parse errors: 0 (0.0%) ⏱️ Timed out: 0 (0.0%) ⏱️ Total time: 31.9ms ``` ### With `silent` flag: ```bash ruby -I lib exe/herb analyze examples --no-log-file --non-interactive --silent --- SUMMARY -------------------------------------------------------------------- Total files: 16 ✅ Successful: 16 (100.0%) ❌ Failed: 0 (0.0%) ⚠️ Parse errors: 0 (0.0%) ⏱️ Timed out: 0 (0.0%) ⏱️ Total time: 35.15ms ```
1 parent 0031bb6 commit 285cbe3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/herb/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def result
110110
project.no_interactive = no_interactive
111111
project.no_log_file = no_log_file
112112
project.no_timing = no_timing
113+
project.silent = silent
113114
has_issues = project.parse!
114115
exit(has_issues ? 1 : 0)
115116
when "parse"

lib/herb/project.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module Herb
1414
class Project
15-
attr_accessor :project_path, :output_file, :no_interactive, :no_log_file, :no_timing
15+
attr_accessor :project_path, :output_file, :no_interactive, :no_log_file, :no_timing, :silent
1616

1717
def interactive?
1818
return false if no_interactive
@@ -106,7 +106,7 @@ def parse!
106106
else
107107
relative_path = file_path.sub("#{project_path}/", "")
108108
end
109-
puts "Processing [#{index + 1}/#{files.count}]: #{relative_path}"
109+
puts "Processing [#{index + 1}/#{files.count}]: #{relative_path}" unless silent
110110

111111
if interactive?
112112
if failed_files.any?
@@ -240,7 +240,7 @@ def parse!
240240
puts "Completed processing all files."
241241
print "\e[H\e[2J"
242242
else
243-
puts "Completed processing all files."
243+
puts "Completed processing all files." unless silent
244244
end
245245

246246
log.puts ""

0 commit comments

Comments
 (0)