# rstodo
[](https://github.com/TiaoFeng/rust-todo-cli/releases/latest)
[](LICENSE)
[](https://www.rust-lang.org/)
A command-line to-do tool written in Rust. It supports adding, deleting, editing, and querying tasks, as well as managing priorities and due dates. Data is stored in JSON files. Although this project began as a practice project for the author while learning Rust, it is still being further optimized and updated. It already offers a fairly comprehensive set of features and can be used as a lightweight tool for everyday tasks.
## Features
- Supports adding, editing, deleting, and marking tasks as completed or uncompleted
- Supports setting task priorities (High / Medium / Low) and due dates
- Supports sorting and displaying tasks by due date or priority
- Supports viewing task details (including descriptions)
- Implements local persistence using JSON files
- Outputs formatted text in a Markdown-like style in the terminal
## Installation
Download the latest precompiled version:
[](https://github.com/TiaoFeng/rust-todo-cli/releases/latest)
or build from source (see the “Building” section below).
## Quick Start (Example)
```
$ cargo run -- add "提交issue"
$ cargo run -- add "修改代码" -d 2000-1-1
$ cargo run -- add "提交commit" -d 2000-1-2 -D "修复潜在的bug"
$ cargo run -- add "审查代码" -d 2000-1-2T12:30:00 -p high
$ cargo run -- list
| | 1 | Low | No | 提交issue | |
| | 2 | Low | 2000-01-01 23:59:59 | 修改代码 | |
| | 3 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
| | 4 | High | 2000-01-02 12:30:00 | 审查代码 | |
$ cargo run -- done 1
$ cargo run -- list
| ✓ | 1 | Low | No | 提交issue | |
| | 2 | Low | 2000-01-01 23:59:59 | 修改代码 | |
| | 3 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
| | 4 | High | 2000-01-02 12:30:00 | 审查代码 | |
$ cargo run -- show 3
| | 3 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
-Description-
修复潜在的bug
$ cargo run -- change 2 -c "修复bug" -d 2000-1-1T12:00:00 -p medium
$ cargo run -- list
| ✓ | 1 | Low | No | 提交issue | |
| | 2 | Medium | 2000-01-01 12:00:00 | 修复bug | |
| | 3 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
| | 4 | High | 2000-01-02 12:30:00 | 审查代码 | |
$ cargo run -- list p
| | 1 | High | 2000-01-02 12:30:00 | 审查代码 | |
| | 2 | Medium | 2000-01-01 12:00:00 | 修复bug | |
| ✓ | 3 | Low | No | 提交issue | |
| | 4 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
$ cargo run -- list d
| | 1 | Medium | 2000-01-01 12:00:00 | 修复bug | |
| | 2 | High | 2000-01-02 12:30:00 | 审查代码 | |
| | 3 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
| ✓ | 4 | Low | No | 提交issue | |
$ cargo run -- delete 1
$ cargo run -- list
| | 1 | High | 2000-01-02 12:30:00 | 审查代码 | |
| | 2 | Low | 2000-01-02 23:59:59 | 提交commit | Show desc |
| ✓ | 3 | Low | No | 提交issue | |
```
## Command Description
### Global Commands
All commands support the following global parameters:
```
--file <FILE> Specify the JSON file to be processed
```
Default file path:
|Linux|~/.local/share/rstodo/task.json|
|macOS|~/Library/Application Support/rstodo/task.json|
|Windows|C:\Users\<user>\AppData\Local\rstodo\task.json|
Global parameters can be placed anywhere in a command:
```
# Place it before the command
rstodo --file ./test1_commands.json list
# Place it after the command
rstodo list --file ./test1_commands.json
```
### Subcommand
#### 1. Add a task
```
rstodo add "{content}" -d {%Y-%m-%dT%h:%m:%s} -D "{description}" -p {priority}
```
Optional Parameters(description,deadline)
```
-D "{description}"
-d {%Y-%m-%d}
-d {%Y-%m-%dT%h:%m:%s}
-p {priority} # Note: Options include “high,” “medium,”
# and “low.” You can enter the numbers 1, 2, or 3. The default is “low.”
```
#### 2. Edit a task
```
rstodo change {no} -c "{content}" -D "{description}" -d {%Y-%m-%dT%h:%m:%s} -p {priority}
```
Optional Parameters(content,description,deadline)
```
-c "{content}"
-D # Note: -D clears the description
-D "{description}"
-d # Note: -d clears the deadline
-d {%Y-%m-%d}
-d {%Y-%m-%dT%h:%m:%s}
-p # Note: -p clears the priority; the default is “low.”
-p {priority} # Note: Includes “high,” “medium,” and “low”;
# you can enter the numbers 1, 2, or 3.
```
#### 3. Display task list
```
rstodo list {SortBy}
```
Optional Parameters(SortBy)
```
{SortBy} # Note: SortBy includes “d” (sort by deadline) and “p” (sort by priority).
```
#### 4. View task details
```
rstodo show {no}
```
#### 5. Done a task
```
rstodo done {no}
```
#### 6. Undone a task
```
rstodo undone {no}
```
#### 7. delete a task
```
rstodo delete {no}
```
## Build from Source Code
```bash
git clone https://github.com/TiaoFeng/rust-todo-cli.git
cd rust-todo-cli
cargo build --release
```
## Project Structure
```
src/
├── main.rs # CLI Command Parsing and Main Program Entry Point
├── commands.rs # Implementation of commands such as add, list, complete, and delete
├── task.rs # The `Task` Structure and Related Methods
├── time.rs # Time Format Conversion and Time Zone Handling
├── error.rs # Error Types Used in the Project
└── io/
├── storage.rs # Reading and Saving a To-Do List
└── cli_print.rs # Terminal table output based on comfy_table
```
## License
This project is licensed under the [MIT License](LICENSE).
## Statement and Acknowledgments
- Claude Sonnet 5, DeepSeek V4 Flash, DeepSeek V4 Pro, Mimo 2.5 Pro, and KIMI K3 provide code reviews and technical guidance.
- [opencode](https://github.com/anomalyco/opencode) offers excellent, open-source tools.
- Translated with DeepL.com (free version)