lib/erb/formatter/command_line.rb in erb-formatter-0.3.0 vs lib/erb/formatter/command_line.rb in erb-formatter-0.4.0

- old
+ new

@@ -31,18 +31,27 @@ @read_stdin = value @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 parser.on("-h", "--help", "Prints this help") do puts parser exit end + + parser.on("-v", "--version", "Show ERB::Formatter version number and quit") do + puts "ERB::Formatter #{ERB::Formatter::VERSION}" + exit + end end.parse!(@argv) end def ignore_list @ignore_list ||= ERB::Formatter::IgnoreList.new @@ -66,10 +75,10 @@ files.each do |(filename, code)| 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) else puts html