Module: ReadwiseCurator::CLIHelpers
- Included in:
- CLI
- Defined in:
- lib/readwise_curator/cli_helpers.rb
Instance Method Summary collapse
- #clear_screen ⇒ Object
- #display_book_count(count) ⇒ Object
- #display_highlight_instructions(highlight_count) ⇒ Object
- #get_category_icon(category) ⇒ Object
- #handle_empty_highlights ⇒ Object
- #handle_no_selection ⇒ Object
- #log_save_success(saved_file) ⇒ Object
- #show_pagination_header(choices, current_page, total_pages, page_size) ⇒ Object
Instance Method Details
#clear_screen ⇒ Object
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_highlights ⇒ Object
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_selection ⇒ Object
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 |