I have decided to rebuild the project in Zig. I would love to have a reason to learn Zig and to use it for something. This project feels like something that would fit the bill.
Let me introduce you to the next version of mt, codename Summit.
I have a few wishes for the implementation:
- Support/be interoperable with task management features as Obsidian Task Management
- Support similar tasks querying as Obsidian Task Management has
- Creating tasks (maybe have configured groups, i.e.
mt group create helloworld -d /path/to/project) - Support
TODOs from all kinds of files (likeTODO: Keep this going), not just Markdown like today. (We might need to cache/keep an index) - Option to create daily task files when adding tasks (adding to
directory/YYYY-MM-DD.md), just a simpleTODO.mdor others?
Potential API for the CLI
mt [command]
If no command is provided, mt will list all tasks in the current directory or the
global note directory if one is configured. If you have configured a global note
directory, you can also specify a different directory to list tasks from:
mt -d ~/notes
Add a task
mt add "Buy milk"
Assuming you have configured a global note directory, this command will add a
new task to the daily note for today. If not, it will add it to TODO.md in the
current directory. You can also specify a different file to add the task to:
mt add "Buy milk" -f ~/notes/TODO.md
You can also add a due date to the task:
mt add "Buy milk" -d 2021年12月31日
The output of this command will be in the format of:
- [ ] Buy milk 📅 2021年04月09日
You can also add a priority to the task:
mt add "Buy milk" -p 1
The priorites can be from 1 to 6, with 1 being the highest priority. You can also
write lowest (6), low (5), none (4), medium (3), high (2) or highest (1) instead.
The output of this command will be in the format of:
- [ ] Buy milk 🔺
Editing a task (i.e. completing it)
I want an interactive mode for editing, but also something that works in the terminal (and can be scripted).
It might be something like:
mt complete 1
List tasks
mt list
Or, just mt with no command. You can specify a different directly to list tasks from:
mt list -d ~/notes
Or mt -d ~/notes with no command. We also have a short version of the command:
mt l
To list all tasks in the current directory, you can use:
mt lc
Tasks
Phase 1: Setup and Core Functionality
Get started with everything, including some form of releasing (and installing).
Basics
- Set up the project structure (e.g., src/, tests/, etc.).
- Configure the build system using Zig's build tools (build.zig).
- Implement a basic CLI framework to handle commands and flags.
- Release on Homebrew?
File Handling
- Write functionality to scan a given directory for files.
- Filter files to only include Markdown files (.md)
Task Extraction
- Parse files to extract lines starting with
- (Markdown tasks).
- Support alternative formats, e.g., lines containing "TODO:".
- Collect all tasks into a data structure.
Phase 2: Task Parsing and Enrichment
- Find files with "TODO:" sections.
Task Parsing
- Parse basic task details (description, completion status).
- Parse emojis for metadata (e.g., 📅 for due dates).
- Parse priority levels from Markdown (🔺, or from flags like -p).
Data Structure
- Define a Task struct with fields like:
description: []u8
dueDate: ?Date
priority: u8
completed: bool
sourceFile: []u8
- Define a TaskList struct for managing multiple tasks.
Phase 3: Command Functionality
List Tasks
- Implement mt list (or mt) to display tasks.
- Support flags for filtering (e.g., by directory -d).
Add Tasks
- Implement mt add to add a new task to the default or specified file.
- Support additional options:
- -d for due dates.
- -p for priorities.
- -f to specify a target file.
Complete Tasks
- Implement mt complete <task_id> to mark tasks as completed.
- Support editing tasks directly in files.
Interactive Mode
- Add an interactive mode for editing tasks (mt edit or mt complete with TUI).
Phase 4: Testing, Docs and Optimizing(?)
Testing
- Write unit tests for core functionalities (e.g., parsing, querying).
- Write integration tests for CLI commands.
Performance
- Profile the tool for performance bottlenecks.
- Optimize file parsing and task querying.
Documentation
- Update README.md with usage examples.
- Add comments and inline documentation in the code.
Phase 5: Advancing?
Caching
- Implement a simple caching system for tasks.
- Use caching to improve performance for repeated queries.
Recurring Tasks
- Add support for recurring tasks using Obsidian-style syntax.
- Parse recurring rules and auto-generate future tasks.
Customization
- Allow user configuration for:
- Global note directory.
- Task priority labels.
- Default output format.