A command-line task processing system that simulates concurrent task execution from a JSON configuration file. This project is created for learning purposes, demonstrating Go's concurrency features using goroutines and channels.
- List all tasks or a specific number of tasks
- Filter tasks by status
- Process tasks concurrently with configurable number of workers
- Real-time task processing notifications with colored output
- JSON-based task configuration
Each task in the JSON file has the following properties:
ID
: Unique identifier for the taskDescription
: Text describing the taskDuration
: Time in seconds the task takes to completeStatus
: Current state of the task (not_started, in_progress, done)
You must have Go installed on your machine.
go build main.go
# View all available commands and options
./main -help
# List all tasks
./main -list
# List specific number of tasks
./main -list -num=5
# Filter tasks by status
./main -status=1 # not_started tasks
./main -status=2 # in_progress tasks
./main -status=3 # done tasks
# Process tasks
./main -process # Process with default 5 workers
./main -process -workers=3 # Process with 3 workers
-file
: Specify the JSON file path (default: "./task.json")-list
: Print the list of all tasks-num
: Use with -list to print a specific number of tasks-status
: Filter tasks by status (1=not_started, 2=in_progress, 3=done)-process
: Start processing tasks that are not yet done-workers
: Number of concurrent workers (default: 5)
not_started
(Status code: 1)in_progress
(Status code: 2)done
(Status code: 3)
Create a task.json file in the following format:
[
{
"id": 1,
"description": "Task description",
"duration": 5,
"status": "not_started"
},
...
]
./main -list -num=3
./main -process -workers=2
./main -status=3
The program uses colored output to indicate task status:
- Red: Not Started
- Yellow: In Progress
- Green: Done
- The program will exit automatically when all tasks are processed
- Task processing is concurrent and the order of completion may vary
- Use Ctrl+C to stop the program during processing