#!/usr/bin/env ruby # Script to run command on my 'bucket' text files @path='/Users/eric/bucket/' def today puts puts " Tasks to do Today" puts "----------------------------" holder = `grep '^*' #{@path}*`.split(/$/) item = 1 holder.slice!(-1) holder.each { |x| re = /:/ re =~ x print "#{item}: #{$'}\n" item += 1 } puts "----------------------------" puts end def project(projectname) puts puts " Output for Project #{projectname}" puts "----------------------------" holder = `grep '(#{projectname})$' #{@path}*`.split(/$/) holder.slice!(-1) item = 1 holder.each { |x| re = /:/ re =~ x print "#{item}: #{$'}\n" item += 1 } puts "----------------------------" puts end def due(date) puts puts " List to be done on #{date}" puts "----------------------------" holder = `grep '#{date}]$' #{@path}*`.split(/$/) holder.slice!(-1) item = 1 holder.each { |x| re = /:/ re =~ x print "#{item}: #{$'}\n" item += 1 } puts "----------------------------" puts end def list_projects puts puts " All projects" puts "----------------------------" holder = `grep ')$' #{@path}projects.txt` item = 1 holder.each { |x| print "#{item}: #{x}" item += 1 } puts "----------------------------" puts end def projects_tasks puts puts " All tasks sorted by project" puts "----------------------------" holder = `grep ')$' #{@path}projects.txt` holder.each { |x| puts puts "Project: #{x}" puts "-------" y = x.chomp innerholder = `grep '#{y}$' #{@path}*`.split(/$/) innerholder.slice!(-1) item = 1 innerholder.each { |z| re = /:/ re =~ z print "#{item}: #{$'}\n" item += 1 } puts "-------" } puts end def number_of_tasks print " Number of next actions is =" holder = `cat #{@path}computer.txt #{@path}home.txt #{@path}inbox.txt #{@path}outside.txt #{@path}read-safari.txt #{@path}read.txt #{@path}waiting.txt | wc -l` print holder puts end def help puts puts " Bucket dump script" puts " -- use `today` to show what is checked for today" puts " -- use `project foo` to show what in the project 'foo'" puts " -- use `due YYYY/MM/DD` to show what is due on YYYY/MM/DD" puts " -- use `all-projects` to show a list of all projects" puts " -- use `project-tasks` to show a listing of all project tasks,\n" + " sorted by project" puts " -- use `number` to show the number of next actions" puts end case ARGV[0] when "today" today when "project" project(ARGV[1]) when "due" # Pass in in ISO format i.e. 2005/10/10 due(ARGV[1]) when "all-projects" list_projects when "project-tasks" projects_tasks when "number" number_of_tasks else help end