Add in occasional message to ask for support
This commit is contained in:
parent
fb90d3cca3
commit
ee3545aa19
|
@ -4,6 +4,10 @@
|
|||
# !/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 <directory>'
|
||||
|
@ -18,3 +22,22 @@ 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user