Introduction

Writing code in Python is fun, but it’s been my daily driver for a while now and I wanted to try some new languages out and see what I’ve been missing. Go and Rust have been at the top of my list; the former because I interact with it from time to time designing Kubernetes infrastructure, and the latter because it’s been a long time since I’ve built anything in a low-level language like C or C++. I opted to try Rust primarily because the ownership system looked intriguing, and much less tedious then the memory management I learned in school.

Overall my experience with the language was resoundingly positive, and I will continue to work on this project in the future. It definitely took time to get immersed into its type system, and debugging compiled code is quite different from my Python workflow. The below code excerpt is the function responsible for moving a list entry from one list to another, pushing and popping the item struct from the respective vectors and writing the JSON representation to file. You can find all of the source code on GitHub here.

Todo Rust Project

Tracking Tasks in the Medium-Term

I use several different mediums for tracking my todo lists: a blank paper journal, plain text files on my computers, and my whiteboard. For projects with long-term continuity, I organize those lists and any other artifacts in Notion. Recently I’ve been thinking it might be more convenient to organize tasks on the medium-term time horizon via the command line. Anything on a list that needs to get done by end of day typically is completed, and entries related to more structured projects are tracked more closely in a version control system like Git or a Notion board. However, entries that need to be completed with a soft deadline in the next several weeks often slip through lists if they aren’t accomplished immediately. If I had a more ergonomic way to store passing thoughts about these tasks via CLI command before they vanish out of mind, I might be able to get more done. This project probably won’t materially impact my productivity, but sometimes it’s fun to reinvent the wheel, especially for the sake of learning a new language.

TL;DR I want to be able to store todo entries via the command line before I forget about them.

Project Scope

Overview

There are three lists: todo, active, and done. They represent tasks that need to be done, are in progress, and are completed, respectively. They store entries in a strictly enforced JSON format. The user should be able to query these lists, optionally using filters, in an easily readible display. They should also be able to add entries from a command line prompt, edit their fields after creation, and move them back and forth between lists.

The following list describes the roadmap of desired features for the application (as clap subcommands):

  • add: Prompt for user input to add a new entry to the todo list
  • edit: Given an entry ID, prompt for user input to edit fields
  • list: Given a list (todo/active/done), list the contents in a formatted table
    • todo:
      • count: Return the count of items in the todo list
      • tags: Return all unique tags and their counts in the todo list
      • (Filter Criteria)
    • active:
      • count: Return the count of items in the active list
      • tags: Return all unique tags and their counts in the active list
      • (Filter Criteria)
    • done:
      • count: Return the count of items in the done list
      • tags: Return all unique tags and their counts in the done list
      • (Filter Criteria)
  • assign: Given a list (todo/active/done), assign an entry to that list by ID
    • todo:
      • item: Move a single item from the active list to the todo list by ID
    • active:
      • item: Move a single item from the todo list to the active list by ID
      • rand: Move a single item from the todo list to the active list, selected at random
        • (Filter Criteria)
    • done:
      • item: Move a single item from the active list to the done list by ID
  • search: Given filter criteria, return a formatted table of the subset of entries
    • (Filter Criteria)

Progress

For this first iteration of the project, I wanted to have three of the subcommands completed to use the application.

Todo Rust Project

Shown above is the general help output, which describes the program usage and the first level of subcommands. The below image shows a help message for a subcommand (list), and which arguments it requires.

Todo Rust Project

Add Tasks

Todo Rust Project

The above image shows the command for adding a new entry to the todo list. There are some simple sanity checks in place, such as checking a valid due date that has not already occurred, and storing the priority and size of tasks as categorical variables. The below image shows the todo list in its actual JSON representation, with the new task added to it.

Todo Rust Project

List Tasks

As shown below, the list command produces a well-formatted table of the entries in a given list.

Todo Rust Project

Assign Tasks

As shown below, it is possible to move an item from one list to another by specifying an item ID.

Todo Rust Project

Moving Forward

In the next post for this project, I will go into the details of my development process with Rust (building with Cargo, debugging, etc.). I will also continue to work on the other features described in the Project Scope. In particular, I’d like to work on robust filtering functionality, to make it easier to list and assign more complex subsets of tasks. The repository also needs to be cleaned up - please excuse all the unwrap() calls. I have work to do on error handling, removing commented code, adding descriptive inline comments, and putting together an actual readme containing installation directions and the roadmap.