Skip to content

Instantly share code, notes, and snippets.

@DrummerHead DrummerHead/gen-task
Created Oct 11, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.