Module: ReadwiseCurator::CLIHelpers

Included in:
CLI
Defined in:
lib/readwise_curator/cli_helpers.rb

Instance Method Summary collapse

Instance Method Details

#clear_screenObject



5
6
7
# File 'lib/readwise_curator/cli_helpers.rb', line 5

def clear_screen
  system("clear") || system("cls")
end

#display_book_count(count) ⇒ Object



20
21
22
23
24
# File 'lib/readwise_curator/cli_helpers.rb', line 20

def display_book_count(count)
  Bridgetown.logger.info "\nšŸ“š Found #{count} items in your Readwise library"
  Bridgetown.logger.info "Icons: šŸ“š Books • šŸ“„ Articles • 🐦 Tweets • šŸŽ§ Podcasts • šŸ“‹ Supplementals"
  Bridgetown.logger.info "* indicates existing page • Use ↑/↓ to navigate, ENTER to select\n\n"
end

#display_highlight_instructions(highlight_count) ⇒ Object



46
47
48
49
50
51
# File 'lib/readwise_curator/cli_helpers.rb', line 46

def display_highlight_instructions(highlight_count)
  Bridgetown.logger.info "\nšŸ“– Found #{highlight_count} highlights for this book"
  Bridgetown.logger.info "Use [↑/↓] to navigate, [SPACE] to select/deselect, " \
                         "[ā†©ļøŽ ENTER] when āœ… done."
  Bridgetown.logger.info "Press [Ctrl+C] to go back to book selection.\n\n"
end

#get_category_icon(category) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/readwise_curator/cli_helpers.rb', line 26

def get_category_icon(category)
  case category&.downcase
  when "books"
    "šŸ“š"
  when "tweets"
    "🐦"
  when "podcasts"
    "šŸŽ§"
  when "supplementals"
    "šŸ“‹"
  else
    "šŸ“„"
  end
end

#handle_empty_highlightsObject



41
42
43
44
# File 'lib/readwise_curator/cli_helpers.rb', line 41

def handle_empty_highlights
  Bridgetown.logger.info "\nšŸ“– Found 0 highlights for this book"
  Bridgetown.logger.info "This book has no highlights to curate."
end

#handle_no_selectionObject



53
54
55
# File 'lib/readwise_curator/cli_helpers.rb', line 53

def handle_no_selection
  Bridgetown.logger.info "No highlights selected."
end

#log_save_success(saved_file) ⇒ Object



57
58
59
# File 'lib/readwise_curator/cli_helpers.rb', line 57

def log_save_success(saved_file)
  Bridgetown.logger.info "Curated highlights saved to #{saved_file}."
end

#show_pagination_header(choices, current_page, total_pages, page_size) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/readwise_curator/cli_helpers.rb', line 9

def show_pagination_header(choices, current_page, total_pages, page_size)
  start_item = (current_page * page_size) + 1
  end_item = [((current_page + 1) * page_size), choices.length].min

  Bridgetown.logger.info "\nšŸ“š Readwise Library (#{choices.length} items)"
  Bridgetown.logger.info "Icons: šŸ“š Books • šŸ“„ Articles • 🐦 Tweets • šŸŽ§ Podcasts • šŸ“‹ Supplementals"
  Bridgetown.logger.info "* indicates existing page"
  Bridgetown.logger.info "Page #{current_page + 1}/#{total_pages} " \
                         "(showing #{start_item}-#{end_item})\n\n"
end