/todo_txt_elixir

A library for interacting with todo.txt and done.txt files per specs defined by http://todotxt.org/

Primary LanguageElixirMIT LicenseMIT

TodoTxt

Online Documentation.

TodoTxt An Elixir library for parseing todo.txt files

About Todo.txt

More information about todo.txt can be found at:

Installation

This package can be installed by adding todo_txt to your list of dependencies in mix.exs:

def deps do
  [
    {:todo_txt, "~> 0.1.0"}
  ]
end

Basic Usage

Read Todos From todo.txt File

todos = 
  File.read!("todo.txt") 
  |> String.split("\n") 
  |> Enum.map(&Todo.parse/1)

Write Todos To todo.txt File

to_write = 
  todos 
  |> Enum.map(&Todo.to_string/1) 
  |> Enum.join("\n")

File.write!("todo.txt.diff", to_write)

Remove Done Todos From todo.txt And Archive Them In done.txt File

todos = File.read!("todo.txt") |> String.split("\n") |> Enum.map(&Todo.parse/1)
{done, todo} = Enum.split_with(todos, fn t -> t.done end)

File.write!("todo.txt", Enum.join(Enum.map(todo, &Todo.to_string/1), "\n"))
File.write!("done.txt", Enum.join(Enum.map(done, &Todo.to_string/1), "\n"))

Roadmap

  • Add a File Watcher for Local todo.txt
  • Add a File Watcher for Google Drive todo.txt