module Diff::LCS::Ldiff

def self.run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:

:nodoc:
def self.run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
  @binary = nil
  args.options do |o|
    o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile"
    o.separator ""
    o.on(
      "-c", "-C", "--context [LINES]", Integer,
      "Displays a context diff with LINES lines", "of context. Default 3 lines."
    ) do |ctx|
      @format = :context
      @lines = ctx || 3
    end
    o.on(
      "-u", "-U", "--unified [LINES]", Integer,
      "Displays a unified diff with LINES lines", "of context. Default 3 lines."
    ) do |ctx|
      @format = :unified
      @lines = ctx || 3
    end
    o.on("-e", "Creates an 'ed' script to change", "oldfile to newfile.") do |_ctx|
      @format = :ed
    end
    o.on("-f", "Creates an 'ed' script to change", "oldfile to newfile in reverse order.") do |_ctx|
      @format = :reverse_ed
    end
    o.on(
      "-a", "--text",
      "Treat the files as text and compare them", "line-by-line, even if they do not seem", "to be text."
    ) do |_txt|
      @binary = false
    end
    o.on("--binary", "Treats the files as binary.") do |_bin|
      @binary = true
    end
    o.on("-q", "--brief", "Report only whether or not the files", "differ, not the details.") do |_ctx|
      @format = :report
    end
    o.on_tail("--help", "Shows this text.") do
      error << o
      return 0
    end
    o.on_tail("--version", "Shows the version of Diff::LCS.") do
      error << Diff::LCS::Ldiff::BANNER
      return 0
    end
    o.on_tail ""
    o.on_tail 'By default, runs produces an "old-style" diff, with output like UNIX diff.'
    o.parse!
  end
  unless args.size == 2
    error << args.options
    return 127
  end
  # Defaults are for old-style diff
  @format ||= :old
  @lines ||= 0
  file_old, file_new = *ARGV
  diff?(
    InputInfo.new(file_old),
    InputInfo.new(file_new),
    @format,
    output,
    binary: @binary,
    lines: @lines
  ) ? 1 : 0
end