diff --git a/TODO b/TODO index eef2ec9..0de995c 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,14 @@ [1] Code the done or archive created:"Thu Jun 11 16:07:47 +0200 2009" [2] Code the filter command created:"Thu Jun 11 16:07:59 +0200 2009" -[3] Code the automatic sort command (it appear to be a complex function) created:"Thu Jun 11 16:08:27 +0200 2009" +[3] Code the automatic sort command (it appear to be a complex function) created:"Thu Jun 11 16:08:27 +0200 2009" [4] Code the modify and extend commands /1\ created:"Thu Jun 11 16:09:24 +0200 2009" [5] Humanize DateTime output created:"Fri Jun 12 20:00:00 +0200 2009" [6] Code a Start/Stop task could be multiple tasks in parallel created:"Fri Jun 12 20:00:00 +0200 2009" [7] Code the standard questionning path for organising tasks created:"Fri Jun 12 20:00:00 +0200 2009" [8] Code a notification system created:"Fri Jun 12 20:00:00 +0200 2009" [9] Code the 2 minutes counter created:"Fri Jun 12 20:00:00 +0200 2009" -[10] Code the x5 method (10+2) created:"Fri Jun 12 20:00:00 +0200 2009" -[11] Code nice done task output (from last week, from last day...) created:"Fri Jun 12 20:00:00 +0200 2009" -[12] Code the hability to have repetitives tasks (every week, every month...) created:"Fri Jun 12 20:00:00 +0200 2009" +[10] Code the x5 method (10+2) created:"Fri Jun 12 20:00:00 +0200 2009" +[11] Code nice done task output (from last week, from last day...) created:"Fri Jun 12 20:00:00 +0200 2009" +[12] Code the hability to have repetitives tasks (every week, every month...) created:"Fri Jun 12 20:00:00 +0200 2009" [13] Recode tag to be able to separate them with commas. created:"Fri Jun 12 20:00:00 +0200 2009" +[14] Code the research of typo in command created:"Tue Jun 16 10:58:55 +0200 2009" diff --git a/todolist.rb b/todolist.rb index 5501d40..5763532 100644 --- a/todolist.rb +++ b/todolist.rb @@ -9,6 +9,10 @@ class TodoList def addTask(task) @todoList << task end + def [] (number) + # we begin at 1 (more natural) + return @todoList[number-1] + end def to_s res="" i=1 @@ -57,6 +61,8 @@ if __FILE__ == $0: todoList.addTask( Task.new(entry.sub(/^(a|\+|add) /,"")) ) when /^[@]/ todoList.addTask( Task.new(entry) ) + when /^p (\d+)/ + puts todoList[Integer($1)].to_s when /^(l|list)( ?(\d*))?/ if $3.length>0: print "number "+$3 end print todoList.to_s diff --git a/ytodo.rb b/ytodo.rb index 176f723..b06bfec 100644 --- a/ytodo.rb +++ b/ytodo.rb @@ -14,9 +14,34 @@ listeEnvVariables<<='autosave' saveFile="TODO" listeEnvVariables<<='saveFile' -def showVariable (varname) - printf '%20s = ', varname - eval "puts "+varname +doneFile="DONE" +listeEnvVariables<<='doneFile' + +# Print help message +def putsHelpMessage + # Vim tips not to loose any command + # :r!grep when ytodo.rb + puts ' + COMMANDS +a,+,add add an entry +cmd,! launch external command +h,help show this message +l,list list the tasks +load,=> [filename] load the tasks from file filename +q,quit quit +s,save [filename] save the tasks to file filename +show [conf key] show the value of a configuration variable + + TIPS +If your entrie is longer than 10 character long and the first +word is not a command. The entrie is added to task. + + REMINDER + @Context [project] (a note) {tag} +Priority: (higher) !! ! "nothing" ? ?? (lower) +Date: #due_date, #start_date,due_date + example: #tomorrow,"in 4 days" + ' end if __FILE__ == $0: @@ -38,15 +63,24 @@ if __FILE__ == $0: todoList.load saveFile while entry = Readline.readline('> ',true): case entry - when /^(a|\+|add) / # ça commence par 'a ' '+ ' ou 'add ' + when /^(a|\+|add) / + # Add en entry todoList.addTask( Task.new(entry.sub(/^(a|\+|add) /,"")) ) if autosave: todoList.save saveFile end when /^(l|list)( ?(\d*))?/ + # list the entries if $3.length>0: print "number "+$3 end print todoList.to_s + when /^(done|archive) (\d*)/ + # archive task + taskNumber=$2 + when /^q(uit)?$/ + # Quit + break when /^(s|save)( (.*))?$/ + # save to file if $3 and $3.length>0: filename=$3 else @@ -55,6 +89,7 @@ if __FILE__ == $0: puts "saving to " + filename todoList.save filename when /^(load|=>) (.*)/ + # load from file if $2.length>0: filename = $2 else @@ -62,29 +97,8 @@ if __FILE__ == $0: end todoList.load filename when /^h(elp)?$/ - # Vim tips not to loose any command - # :r!grep when ytodo.rb - puts ' - COMMANDS -a,+,add add an entry -cmd,! launch external command -h,help show this message -l,list list the tasks -load,=> [filename] load the tasks from file filename -q,quit quit -s,save [filename] save the tasks to file filename -show [conf key] show the value of a configuration variable - - TIPS -If your entrie is longer than 10 character long and the first -word is not a command. The entrie is added to task. - - REMINDER - @Context [project] (a note) {tag} -Priority: (higher) !! ! "nothing" ? ?? (lower) -Date: #due_date, #start_date,due_date - example: #tomorrow,"in 4 days" - ' + putsHelpMessage + # show help message when /^(show)( (.*))?$/ varname=$3 if varname and (varname.length>0): @@ -114,17 +128,16 @@ Date: #due_date, #start_date,due_date begin eval $1+"="+$3 end - when /^q(uit)?$/ - break when /^(!|cmd )(.+)$/ system( $2 ) - # must be the last two entries + # DEV # must be the last two entries # DEV # when /^$/ + # do nothing when there is no entry when /^.{1,10}$/ # if the entry is not # recognized and less than 10 characters # long then we output an error - print "/!\\ Commande inconnue /!\\\n" + print "/!\\ Unknown command /!\\\n" else # if the entry is more than 10 characters long # and not recognized then it is a new entry