Skip to content

Instantly share code, notes, and snippets.

@46bit
Created April 25, 2012 13:13
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 46bit/2489609 to your computer and use it in GitHub Desktop.
Save 46bit/2489609 to your computer and use it in GitHub Desktop.
Plan your day
#!/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
@46bit
Copy link
Author

46bit commented Apr 25, 2012

(I probably should find out how to use $EDITOR neatly. That can't be the right way, surely?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment