fotos 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env ruby
  2. require 'fotos'
  3. require 'optparse'
  4. COMMANDS = %w(extract organize build)
  5. parser = OptionParser.new
  6. case ARGV[0]
  7. when 'extract'
  8. parser.on('-z PATH', '--zip', 'Extract a zip file with images from PATH')
  9. parser.on('-d [PATH]', '--dest', 'Copy to a destinatio dir')
  10. options = {dest: '.'}
  11. parser.parse!(into: options)
  12. Fotos::ZipExtractor.new(options).call
  13. when 'organize'
  14. options = {}
  15. parser.on('-s [PATH]', '--source', 'Input directory with image directories')
  16. parser.on('-d [PATH]', '--destination', 'Copy to a destinatio dir')
  17. parser.parse!(into: options)
  18. Fotos::Organizer.new(options).call
  19. when 'build'
  20. parser.on('-s [PATH]', '--source', 'Input directory with image directories')
  21. parser.on('-d [PATH]', '--dest', 'Output directory for html and images')
  22. parser.on('-t', '--thumbnails', 'Automatically generate missing thumbnails')
  23. options = {dest: '.'}
  24. parser.parse!(into: options)
  25. Fotos::HtmlGenerator.new(options).call
  26. else
  27. puts "Unknown command! Available commands: #{COMMANDS.join(',')}."
  28. exit(-1)
  29. end