Language: ไธญๆ | English
A simple yet powerful command-line todo application written in Go.
- ๐ Add new todo items
- ๐ List all todo items
- โ Mark todos as complete
- ๐๏ธ Delete todo items
- ๐พ Persistent storage using JSON format
- ๐ข Smart index management (continuous display numbers)
- ๐ก๏ธ Secure ID generation mechanism
- ๐ฏ Modern subcommand interface with Cobra
- ๐ Backward compatibility with flag-based usage
- ๐ Auto-generated help documentation
- ๐จ Command aliases for better user experience
Prerequisites: Go 1.19 or higher required
# Install the latest version
go install github.com/jerryhanjj/todo-app-cli@latest
# Or install a specific version (e.g., v1.0.0)
go install github.com/jerryhanjj/todo-app-cli@v1.0.0
# Run the application
todo-app-cli listPrerequisites: Go 1.19 or higher required
# 1. Clone the repository
git clone https://github.com/jerryhanjj/todo-app-cli.git
cd todo-app-cli
# 2. Build the executable
go build -o todo main.go
# 3. Run the application
./todo list# Clone the repository
git clone https://github.com/jerryhanjj/todo-app-cli.git
cd todo-app-cli
# Run directly (recompiles each time)
go run main.go list# Clone the repository
git clone https://github.com/jerryhanjj/todo-app-cli.git
cd todo-app-cli
# Build using Makefile
make build
# Run the application
./todo list
# Or run directly in development mode
make run ARGS="list"
make run ARGS="add 'New Task'"# In the project directory
go build -o todo main.go
# Move to system PATH directory (optional)
sudo mv todo /usr/local/bin/
# Or use Makefile
make install
# Now you can use it anywhere
todo list# View help information
./todo --help
# Modern subcommand approach (recommended)
./todo add "Learn Go programming"
./todo list
./todo complete 1
./todo delete 2
# Legacy flag approach (backward compatible)
./todo -a "Learn Go programming"
./todo -l
./todo -c 1
./todo -d 2This tool supports two usage approaches - choose based on your preference:
./todo add "Buy groceries" # Add todo
./todo list # View list
./todo complete 1 # Complete item 1
./todo delete 2 # Delete item 2./todo -a "Buy groceries" # Add todo
./todo -l # View list
./todo -c 1 # Complete item 1
./todo -d 2 # Delete item 2# View main command help
./todo --help
# View subcommand help
./todo add --help
./todo list --help
./todo complete --help
./todo delete --help# Subcommand style
./todo add "Buy groceries"
./todo add "Write code"
./todo add "Exercise"
# Flag style
./todo -a "Buy groceries"
./todo --add "Write code"# Subcommand style
./todo list
# Or use aliases
./todo ls
./todo l
# Flag style
./todo -l
./todo --listExample output:
Todos:
[โ] 1: Learn Go programming
[ ] 2: Buy groceries
[ ] 3: Write code
# Complete a todo using its index number
# Subcommand style
./todo complete 2
# Or use aliases
./todo done 2
./todo c 2
# Flag style
./todo -c 2
./todo --complete 2# Delete a todo using its index number
./todo delete 3
# Or use aliases
./todo del 3
./todo d 3
./todo rm 3
# Flag style
./todo -d 3
./todo --delete 3| Command | Aliases | Description | Example |
|---|---|---|---|
add |
- | Add a new todo item | todo add "Buy groceries" |
list |
ls, l |
Display all todo items | todo list |
complete |
done, c |
Mark todo as complete | todo complete 1 |
delete |
del, d, rm |
Delete a todo item | todo delete 2 |
help |
- | Show help information | todo help |
| Short Flag | Long Flag | Description | Example |
|---|---|---|---|
-a |
--add |
Add a new todo item | todo -a "Buy groceries" |
-l |
--list |
Display all todo items | todo -l |
-c |
--complete |
Mark todo as complete | todo -c 1 |
-d |
--delete |
Delete a todo item | todo -d 2 |
-h |
--help |
Show help information | todo -h |
| ./todo help |
## ๐ Project Structure
todo-app-cli/ โโโ main.go # Application entry point โโโ internal/ โ โโโ todo/ โ โโโ todo.go # Todo logic and data structures โโโ data/ โ โโโ todos.json # JSON format persistent storage โโโ Makefile # Build and development tools โโโ go.mod # Go module file โโโ go.sum # Go dependency checksum file โโโ LICENSE # License file โโโ README_ZH.md # Project documentation (Chinese) โโโ README.md # Project documentation (English)
## ๐ง Development Setup
### Prerequisites
- Go 1.19+ ([Installation Guide](https://golang.org/doc/install))
- Git
### Local Development
```bash
# 1. Clone the project
git clone https://github.com/jerryhanjj/todo-app-cli.git
cd todo-app-cli
# 2. Install dependencies (if any)
go mod tidy
# 3. Use Makefile for development
make run ARGS="list" # Run list command
make run ARGS="add 'Test'" # Add a todo item
make build # Build executable
make test # Run tests
make fmt # Format code
make clean # Clean build files
# 4. Or use traditional way
go run main.go list
go build -o todo main.go
make help # View all available commands
make build # Build the application
make run ARGS="..." # Run in development mode
make test # Run tests
make clean # Clean build files
make install # Install to system PATH
make fmt # Format code
make vet # Vet code- Display continuous index numbers (1, 2, 3...), even after deleting middle items
- User operations use index numbers, while internal unique IDs are maintained
- Eliminates the confusion of index gaps
- All data is saved in
data/todos.jsonfile - Automatically creates data directory and file
- JSON format for easy viewing and debugging
- Comprehensive boundary checking
- User-friendly error messages
- Prevention of invalid operations
Contributions are welcome! Please follow these steps:
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details
- Add todo priority levels
- Support todo categories/tags
- Add due date functionality
- Export functionality (JSON, CSV, TXT, etc.)
- Search and filter functionality
- Colored output
- Command-line auto-completion
- Configuration file support
- โ Major Upgrade: Migrated from pflag to Cobra framework
- โ
Modern subcommand interface (
todo add,todo list, etc.) - โ
Backward Compatibility: Still supports legacy flags (
-a,-l,-c,-d) - โ
Command aliases support (
ls,done,del, etc.) - โ Auto-generated help documentation
- โ Improved code organization with separate command files
- โ Enhanced user experience with better error handling
- โ Foundation for future feature expansions
- โ Basic CRUD functionality
- โ JSON persistent storage
- โ Smart index management
- โ User-friendly error messages
- โ pflag-based command line interface
If you encounter any issues or have suggestions, please:
- Create an Issue
- Email: jerryhanjj@126.com
- Star โญ this project on GitHub
Thanks to all developers who have contributed to this project!
Special thanks to:
- The Go community for excellent documentation and tools
- Contributors who help improve this project
Happy Coding! ๐