class SafariBookmarksParser::Commands::DupsCommand
Attributes
exclude_reading_list[R]
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
SafariBookmarksParser::Commands::BaseCommand::new
# File lib/safari_bookmarks_parser/commands/dups_command.rb, line 8 def initialize(argv) @exclude_reading_list = false super end
Public Instance Methods
run()
click to toggle source
# File lib/safari_bookmarks_parser/commands/dups_command.rb, line 14 def run plist_parser = Parser.parse(@plist_path) bookmarks = bookmarks_to_process(plist_parser).to_a duplicated_bookmark_groups = Services::FindDuplicatedBookmarks.call(bookmarks: bookmarks) return if duplicated_bookmark_groups.empty? duplicated_bookmark_groups = duplicated_bookmark_groups.map do |group| group.map(&:to_h) end text = format_to_text(duplicated_bookmark_groups) output_text(text) end
Private Instance Methods
bookmarks_to_process(plist_parser)
click to toggle source
# File lib/safari_bookmarks_parser/commands/dups_command.rb, line 34 def bookmarks_to_process(plist_parser) if @exclude_reading_list plist_parser.root_folder_without_reading_list else plist_parser.root_folder end end
on_exclude_reading_list(parser)
click to toggle source
# File lib/safari_bookmarks_parser/commands/dups_command.rb, line 55 def on_exclude_reading_list(parser) parser.on('-R', "Exclude reading list (default: #{@exclude_reading_list})") do @exclude_reading_list = true end end
parse_options(argv)
click to toggle source
# File lib/safari_bookmarks_parser/commands/dups_command.rb, line 42 def parse_options(argv) parser = OptionParser.new parser.banner = "Usage: #{parser.program_name} dups [options] [~/Library/Safari/Bookmarks.plist]" on_output_path(parser) on_output_format(parser) on_exclude_reading_list(parser) do_parse(parser, argv) end