#!/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"