lib/erb/formatter/command_line.rb in erb-formatter-0.4.3 vs lib/erb/formatter/command_line.rb in erb-formatter-0.5.0
- old
+ new
@@ -8,11 +8,11 @@
def initialize(argv, stdin: $stdin)
@argv = argv.dup
@stdin = stdin
- @write, @filename, @read_stdin, @code = nil
+ @write, @filename, @read_stdin, @code, @single_class_per_line = nil
OptionParser.new do |parser|
parser.banner = "Usage: #{$0} FILENAME... --write"
parser.on("-w", "--[no-]write", "Write file") do |value|
@@ -35,10 +35,14 @@
parser.on("--print-width WIDTH", Integer, "Set the formatted output width") do |value|
@width = value
end
+ parser.on("--single-class-per-line", "Print each class on a separate line") do |value|
+ @single_class_per_line = value
+ end
+
parser.on("--[no-]debug", "Enable debug mode") do |value|
$DEBUG = value
end
parser.on("-h", "--help", "Prints this help") do
@@ -75,10 +79,10 @@
files.each do |(filename, code)|
if ignore_list.should_ignore_file? filename
print code unless write
else
- html = ERB::Formatter.new(code, filename: filename, line_width: @width || 80)
+ html = ERB::Formatter.new(code, filename: filename, line_width: @width || 80, single_class_per_line: @single_class_per_line)
if write
File.write(filename, html)
else
puts html