Start with mood tracker

parents
#!/bin/env ruby
require 'pp'
require 'chronic'
DEBUG = false
moodfile = "#{ENV['HOME']}/.mood"
if ARGV.empty?
system("tail #{moodfile}")
return
end
mood = ARGV[0].to_i
userdate = ARGV.find{|a| a.match(/^date=/) }&.split('=')&.last
if userdate
date = Chronic.parse(userdate)
end
date ||= Time.new.to_s
file = File.open(moodfile, 'a+')
if !DEBUG
file << "\n#{date},#{mood}"
end
file.close
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment