~mrshll1001/todo-py

Python implementation of todo-txt-cli, written to learn about argparsing and String parsing in Python.
165b49a1 — Matt Marshall 1 year, 10 months ago
Edited README to reflect new configuration style
6da7cf7e — Matt Marshall 1 year, 10 months ago
Removed requirements.txt as there are no requirements that are required by pip anymore
215e1615 — Matt Marshall 1 year, 10 months ago
removed old yaml call on edit function

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~mrshll1001/todo-py
read/write
git@git.sr.ht:~mrshll1001/todo-py

You can also use your local clone with git send-email.

#todo.py

I get it. Everyone and their dog has written a python implementation of the famous todo.sh cli for todo.txt. A very brief search uncovers at least two prominent ones: a "no-BS" implementation from mattr555 and "yet another" implementation from alapolloni.

The main features of todo.sh are mostly implemented with a few esoteric ones ommitted. You can add, do, rm, pri depri, lspri, lsprj, lsc, app|append, prep|prepend. You can also now count, projects, contexts, git, and edit.

#Setup

Download this repo and ensure todo.py is executable. You will also want to create ~/.config/todo-py/config.json with the following template:

{
  "text-editor": "your-fave-text-editor-here",
  "todo-file": "/home/yourname/todo/todo.txt",
  "done-file": "/home/yourname/todo/done.txt",
  "git-dir": "/home/yourname/todo"
}

You may want to add todo.py to your $PATH or otherwise alias it. I alias it to t in .bash_aliases.

#config.json

config.json is the config file for the project. It should live in ~/.config/todo-py/config.json. In the future, todo-py will support the XDG_CONFIG_HOME environment variable and in the future it will also support automatic creation of the config file if it doesn't exist.

You can set the following variables:

  • text-editor configures which program your todo.txt is opened in using the edit command, for when you're editing manually.
  • todo-file configures the file for storing your active todo items.
  • done.txt configures the file for storing completed todo items.
  • git-dir configures the git repo for git manipulation (if you're using it). Don't add the trailing slash to the path (see the example above). The reason that it's separate is that you may want to specify that the git repo sits somewhere above the directory for your todo files.

#todo-py additional commands

#count

This is simple and just returns the number of items in the file.

#projects and contexts

While lsprj and lsc simply list the projects and contexts that are in the todo file, these commands will output the projects or contexts respectively with their associated todo lines underneath them. This way you can get an overview of what you've got on.

Todo items with multiple projects and contexts will appear multiple times in the output. The output of each list underneath the header is sorted according to normal todo.txt sorting rules ie alphabetically and thus priorities at the top

#git

The main additional feature of this implementation is the git committing and the passing on arguments for git commandline usage via t git [git commands] (see below for why). Thus to initialise the repo in a new folder just type t git init, and then pass on git commands as normal via t git [git commands] to set the head etc. If the git repo is initialised all changes to todo.txt and done.txt are committed automatically with a plain english commit message. If you want to use it without the git repo this is harmless.

#edit

edit was my favourite todo.sh extension. The edit command here allows you to quickly open your todo.txt file in a text editor of your choice.

This is configured in config.yml using the variable text-editor. The default is nano.

#Why?

I'm a big fan of plaintext and commandline tools when they're well designed. Two of my favourites are the aforementioned todo.sh and pass, the standard unix password manager. Pass has a beautifully designed feature where it has an inner git repository that, when initialised, will automatically commit changes to the directory when adding/editing/deleting passwords. Then you can run pass git [git command] to manipulate the repository and push/pull changes when you're ready. I wanted a similar feature for my other most-heavily used commandline tool: todo.sh.

Sure there's the sync extension in the extensions repo, but it would often create conflicts and would rely on me running the sync command to capture lines. If I fell behind I'd end up with a commit which changed lots of lines and change history would be lost. Plus the commit messages were naff.

That's the prime feature I wanted in and once I peered at the source for both todo.sh and pass I realised my bash wasn't good enough. So I hunted and found those python implementations. Then I realised that either my python wasn't quite good enough to modify other people's code to implement the exact feature I want or nobody knew what they were doing and I should just try anyway.

I also, importantly, wanted to have fun and learn a bit more about string and file manipulation in python.