Ajout des fonctionnalités 'help' et 'show'

This commit is contained in:
Yann Esposito 2009-06-08 14:40:45 +02:00
parent f5fc8ced30
commit 5abbf58ea9

View file

@ -25,16 +25,22 @@ class TodoList
def load(filename)
begin
f=File.open(filename, 'r')
nbTasks=0
while (line=f.readline)
puts "ajout de "+line[4..-2]
addTask( Task.new(line[4..-2]) )
# delete the number ([...]) and
# the newline character
line.match(/\[[^\]]*\] (.*)[\r\n]$/)
line=$1
addTask( Task.new(line) )
nbTasks+=1
end
rescue Errno::ENOENT
puts "no such file #{filename}"
rescue EOFError
puts "Loaded "+nbTasks.to_s+" entries from "+filename
f.close
rescue IOError => e
puts e.exception
rescue EOFError
f.close
end
end
end
@ -42,7 +48,6 @@ end
if __FILE__ == $0:
todoList=TodoList.new
defaultTaskFile="tasks.ytd"
print defaultTaskFile+"\n"
todoList.load defaultTaskFile
while true:
print "> "