Todo_Marker/bin/todo_marker

44 lines
1014 B
Plaintext
Raw Normal View History

2024-06-14 23:00:56 -06:00
# frozen_string_literal: true
2024-06-14 22:59:20 -06:00
# bin/todo_marker
2024-06-14 23:00:56 -06:00
# !/usr/bin/env ruby
2024-06-14 22:59:20 -06:00
2024-06-14 23:00:56 -06:00
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')
2024-06-14 22:59:20 -06:00
if ARGV.empty?
2024-06-14 23:00:56 -06:00
puts 'Usage: todo_marker <directory>'
2024-06-14 22:59:20 -06:00
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