Skip to content

Instantly share code, notes, and snippets.

@ox
Created October 6, 2012 18:07
Show Gist options
  • Save ox/3845662 to your computer and use it in GitHub Desktop.
Save ox/3845662 to your computer and use it in GitHub Desktop.
A ruby CLI program to manage tasks
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