Created
April 25, 2012 13:13
-
-
Save 46bit/2489609 to your computer and use it in GitHub Desktop.
Plan your 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 'optparse' | |
options = { } | |
optparse = OptionParser.new do |opts| | |
opts.banner = "Plan your day through the cli.\n" | |
opts.banner += "Usage: plan [-e|--edit]" | |
options[:edit] = false | |
opts.on('-e', '--edit', 'Edit the plan') do | |
options[:edit] = true | |
end | |
opts.on('-h', '--help', 'Display this screen') do | |
puts opts | |
exit | |
end | |
end | |
optparse.parse! | |
file = "#{ENV['HOME']}/plan.plan" | |
if options[:edit] | |
editor = ENV['EDITOR'] || 'vim' | |
`#{editor} #{ENV['HOME']}/plan.plan` | |
exit | |
end | |
puts File.read file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(I probably should find out how to use $EDITOR neatly. That can't be the right way, surely?)