Last active
June 21, 2023 08:07
-
-
Save dan-palmer/8cfb42d65a1234d9adc96e8ac431aff7 to your computer and use it in GitHub Desktop.
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
unless File.exists?("~/.todos/"), do: File.mkdir!("~/.todos/") | |
case System.argv() do | |
["all"] -> | |
if (files = File.ls!("~/.todos/")) == [], | |
do: IO.puts("No todos."), | |
else: Enum.each(files, &IO.puts("- #{&1}\n#{File.read!("#{"~/.todos/"}#{&1}")}\n")) | |
["create", todo] -> | |
File.write!("#{"~/.todos/"}#{:os.system_time(:second)}", todo) && IO.puts("๐") | |
[action, id] when action in ~w(complete delete) -> | |
File.rm!("#{"~/.todos/"}#{id}") && IO.puts(if action == "delete", do: "๐๏ธ", else: "โ ") | |
_else -> | |
IO.puts("watcha talkin bout willis") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
elixir todo.ex all