# frozen_string_literal: true # bin/todo_marker # !/usr/bin/env ruby require 'todo_marker' require 'date' DONATION_LINK = 'https://www.paypal.com/donate/?hosted_button_id=YF5XS7ZXQ6F8A' TIMESTAMP_FILE = File.join(Dir.home, '.todo_marker_last_donation_prompt') if ARGV.empty? puts 'Usage: todo_marker ' exit 1 end directory = ARGV[0] unless Dir.exist?(directory) puts "Directory #{directory} does not exist" exit 1 end TodoMarker.generate_todo_md(directory) puts "TODO.md has been generated in the #{directory} directory." def should_show_donation_message? return true unless File.exist?(TIMESTAMP_FILE) last_prompt = Date.parse(File.read(TIMESTAMP_FILE).strip) (Date.today - last_prompt).to_i >= 7 # Show message once a week rescue ArgumentError true end def update_timestamp File.write(TIMESTAMP_FILE, Date.today.to_s) end if should_show_donation_message? puts "\nEnjoying TodoMarker? Consider donating to support development:" puts DONATION_LINK update_timestamp end