lib/iphoto_backup/cli.rb in iphoto_backup-1.0.2 vs lib/iphoto_backup/cli.rb in iphoto_backup-1.1.0

- old
+ new

@@ -11,10 +11,11 @@ desc "export [OPTIONS]", "exports iPhoto albums into target directory" option :filter, desc: 'filter to only include albums that match the given regex', aliases: '-e', default: '.*' option :output, desc: 'directory to export albums to', aliases: '-o', default: DEFAULT_OUTPUT_DIRECTORY option :config, desc: 'iPhoto AlbumData.xml file to process', aliases: '-c', default: IPHOTO_ALBUM_PATH option :'include-date-prefix', desc: 'automatically include ISO8601 date prefix to exported events', aliases: '-d', default: false, type: :boolean + option :albums, desc: 'export albums instead of events', aliases: '-a', default: false, type: :boolean def export each_album do |folder_name, album_info| say "\n\nProcessing Roll: #{folder_name}..." each_image(album_info) do |image_info| @@ -36,19 +37,23 @@ default_command :export private def each_album(&block) - albums = value_for_dictionary_key("List of Rolls").children.select {|n| n.name == 'dict' } + albums = value_for_dictionary_key(album_type).children.select {|n| n.name == 'dict' } albums.each do |album_info| folder_name = album_name album_info if folder_name.match(album_filter) yield folder_name, album_info else say "\n\n#{folder_name} does not match the filter: #{album_filter.inspect}" end end + end + + def album_type + options[:album] ? 'List of Albums' : 'List of Rolls' end def album_name(album_info) folder_name = value_for_dictionary_key('RollName', album_info).content