Skip to content

Instantly share code, notes, and snippets.

@DrummerHead
Created October 11, 2016 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrummerHead/6209125e8fea6b7513cb36d34eb242ba to your computer and use it in GitHub Desktop.
Save DrummerHead/6209125e8fea6b7513cb36d34eb242ba to your computer and use it in GitHub Desktop.
Write a markdown file for documenting the tasks of the day
#!/usr/bin/env ruby
require 'time'
def titleForMd argument
argument ? " - #{argument}" : ''
end
def titleForFilename argument
argument ? argument.gsub(/\s/, '-') : 'tasks'
end
def template params
%{# Tasks for the day #{params[:today]}#{params[:title]}
- [ ]
- [ ]
- [ ]
- [ ]
- [ ]
}
end
# https://ruby-doc.org/core-2.3.0/Time.html#method-i-strftime
today = Time.now.strftime "%Y-%m-%d"
filename = "#{today}--#{titleForFilename ARGV[0]}.md"
File.write(filename, template({today: today, title: titleForMd(ARGV[0])}))
puts "\nFile #{filename} created\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment