Skip to content

Commit

Permalink
Merge pull request #13 from nebulab/elia/print-width
Browse files Browse the repository at this point in the history
Add option to set width to the CLI
  • Loading branch information
nbelzer authored Jan 18, 2023
2 parents 661ce21 + 0e33d3b commit 17cef4d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/erb/formatter/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def initialize(argv, stdin: $stdin)
@filename ||= '-'
end

parser.on("--print-width WIDTH", Integer, "Set the formatted output width") do |value|
@width = value
end

parser.on("--[no-]debug", "Enable debug mode") do |value|
$DEBUG = value
end
Expand Down Expand Up @@ -68,7 +72,7 @@ def run
if ignore_list.should_ignore_file? filename
print code unless write
else
html = ERB::Formatter.format(code, filename: filename)
html = ERB::Formatter.new(code, filename: filename, line_width: @width || 80)

if write
File.write(filename, html)
Expand Down

0 comments on commit 17cef4d

Please sign in to comment.