Guest User

Todox.rb

a guest
Aug 17th, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.29 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. CLR_BLACK = "\e[1;30m"    #Black
  3. CLR_RED = "\e[1;31m"        #Red
  4. CLR_GREEN = "\e[1;32m"    #Green
  5. CLR_YELLOW = "\e[1;33m"    #Yellow
  6. CLR_BLUE = "\e[1;34m"        #Blue
  7. CLR_MAGENTA = "\e[1;35m"    #Magenta
  8. CLR_CYAN = "\e[1;36m"        #Cyan
  9. CLR_WHITE = "\e[1;37m"    #White
  10. CLR_DEFAULT = ""
  11. CLR_CLEAR = "\e[0m";
  12. DONE_TAG = "@done"
  13.  
  14. TODO_TO_USE = "todo.taskpaper"
  15.  
  16. def outtext (txt,clr)
  17.     if (clr == "") then
  18.         puts txt
  19.     else
  20.         puts clr+txt+CLR_CLEAR
  21.     end
  22. end
  23.  
  24. def list_tag (tagtitle,tagname,clr,clrtitle,showall)
  25.     project = "???"
  26.     titleshown = false
  27.     File.open(TODO_TO_USE, "r") do |infile|
  28.         while (line = infile.gets)
  29.             line = line.gsub(/- /,"")
  30.             # if it is project name line take project name
  31.             if (/#*:/.match line) then
  32.                 project = line
  33.             end
  34.             # if done then skip
  35.             if (line.include? DONE_TAG) then
  36.                 next
  37.             end
  38.             # if tag matches
  39.             if (line.include? tagname) then
  40.                 if not titleshown then
  41.                     if not (tagtitle=="") then
  42.                         outtext(tagtitle,clrtitle)
  43.                         puts ""
  44.                         titleshown = true
  45.                     end
  46.                 end
  47.                 if (showall == true) then
  48.                     if (line.include? "@urgent") then
  49.                         outtext("    "+project.strip+" "+line.strip,CLR_RED)
  50.                     else
  51.                         outtext("    "+project.strip+" "+line.strip,clr)
  52.                     end
  53.                 else
  54.                     outtext("*** "+project.strip.upcase+" "+line.strip.gsub(/ @now/,"").upcase+" ***   ","")
  55.                     exit
  56.                 end
  57.         end
  58.         end
  59.         infile.close
  60.     end
  61.     if titleshown then
  62.         puts ""
  63.     end
  64. end
  65.  
  66. if (ARGV.length == 0) then
  67.     list_tag("@NOW","@now",CLR_YELLOW,CLR_WHITE,true)
  68.     list_tag("@TODAY","@today",CLR_DEFAULT,CLR_WHITE,true)
  69.     list_tag("@SOON","@soon",CLR_BLACK,CLR_WHITE,true)
  70.     list_tag("@LATER","@later",CLR_BLACK,CLR_WHITE,true)
  71.     list_tag("@FOLLOWUP","@followup",CLR_BLACK,CLR_BLACK,true)
  72.     exit
  73. end
  74.  
  75. list_tag("","@now","","",false)
  76. outtext("*** NOTHING TO DO? ***   ","")
Advertisement
Add Comment
Please, Sign In to add comment