#!/usr/bin/ruby
# frozen_string_literal: true

require 'exif'

def usage
  warn "Usage: #{$PROGRAM_NAME} filename [filenames...]"
  exit 1
end

usage if ARGV.empty?

ARGV.each do |path|
  unless File.file?(path)
    warn "#{path}: not found"
    next
  end

  exif = Exif.new(path)
  puts "#{path}:"
  puts "  byte order: #{exif.byte_order}"
  puts "  ifd: #{exif.ifd || 'any'}"

  printed = false
  exif.each_entry do |tag, value|
    printf "  TAG %-40.40s %s\n", tag, value
    printed = true
  end
  puts "  (no EXIF entries)" unless printed
  puts
end
