Created
October 11, 2016 13:37
-
-
Save DrummerHead/6209125e8fea6b7513cb36d34eb242ba to your computer and use it in GitHub Desktop.
Write a markdown file for documenting the tasks of the day
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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