#! /usr/bin/env ruby $LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__))) require 'optparse' require 'photoapp' options = {} OptionParser.new do |opts| opts.on("-c", "--config PATH", String, "Path to config file") do |config| options['config'] = config end opts.on("-v", "--version", "Version Number") do options['version'] = true end end.parse! def update %w(Reprint Update).each do |app| system "rm -rf /Applications/#{app}.app" system "cp -r #{Photoapp.gem_dir("assets/#{app}.app")} /Applications/" end folder_actions_path = File.expand_path("~/Library/Workflows/Applications/Folder\\ Actions/") system "mkdir -p #{folder_actions_path}" system "rm -rf #{File.join(folder_actions_path, "photoapp-process.workflow")}" system "cp -r #{Photoapp.gem_dir('assets/photoapp-process.workflow')} #{folder_actions_path}" end def actions system "open /System/Library/Image\\ Capture/Support/Application/AutoImporter.app" system "open /System/Library/CoreServices/Folder\\ Actions\\ Setup.app" end def setup if `brew list imagemagick` =~ /Error:/ system "brew update && brew install imagemagick" end unless `ls /Library/Automator` =~ /Import Files into Photos/ system "say 'please install Automator actions for Photos app'" system "open #{Photoapp.gem_dir('assets/photos-action-installer.pkg')}" end update actions end if options['version'] puts Photoapp::VERSION abort end cmd = ARGV.shift case cmd when 'config' case ARGV.shift when 'printer' system 'open http://127.0.0.1:631/printers/' system 'say "Choose the printer you want to configure"' sleep 3 system 'say "Select Set Default Options from the Administration drop-down."' sleep 3 system 'say "then configure your printer based on the settings you see here"' sleep 3 system 'open https://github.com/imathis/desoto-photoapp#default-printer-settings' when 'import' system 'say "launching AutoImporter, press command comma to change settings"' system 'open /System/Library/Image\ Capture/Support/Application/AutoImporter.app' when 'action' system 'open /System/Library/CoreServices/Folder\ Actions\ Setup.app' system 'say "Add an action for the cave.pics/import folder and select the photoapp process workflow from the list. Then close the app."' end when 'test' path = ARGV.join('') session = Photoapp::Session.new(options) session.test_image(path) when 'setup' setup when 'update' update when 'set-actions' actions when 'process' options['source'] = ARGV.shift Photoapp::Session.new(options).process when 'upload' Photoapp::Session.new(options).upload when 'reprint' Photoapp::Session.new(options).reprint end