Created
October 6, 2012 18:07
-
-
Save ox/3845662 to your computer and use it in GitHub Desktop.
A ruby CLI program to manage tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File.open("text.txt", "a+") do |f| | |
f.seek(0) | |
tasks = f.lines.to_a | |
tasks.delete_at(ARGV[1].to_i) if ARGV[0] == "d" and !ARGV[1].nil? and ARGV[1].to_i | |
tasks << ARGV.join(" ") unless ARGV[0] == "d" or ARGV.empty? | |
File.open("text.txt", "w") {|g| g.puts tasks; tasks.each_with_index {|t, i| puts "#{i}: #{t}"} } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment